(function(){window.JCCodeEditor=function(t,e){this.actionCount=0;this.arConfig=t;this.MESS=e;this.arSyntaxes={};this.pTA=BX(this.arConfig.textareaId);if(!this.pTA||!BX.isNodeInDom(this.pTA))return false;this.saveSettings=!!t.saveSettings;this.highlightMode=!!t.highlightMode&&this.IsValidBrowser();this.theme=t.theme;this.tabSize=4;this.undoDepth=30;this.timeout=100;this.delay=200;this.pollInterval=100;this.cursorInterval=500;this.indentUnit=4;this._cachedWidthFor=0;this._cachedWidth=0;this.prevInput="";this._cachedHeight=null;this._cachedHeightFor=null;this._measurePre=null;this.lineNums=0;this.tabSymTA="        ";this.arBrackets={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"};this.Init()};window.JCCodeEditor.prototype={Init:function(){var t=this;if(this.pTA.parentNode.offsetWidth<=0||this.pTA.parentNode.offsetHeight<=0){return setTimeout(function(){t.Init()},100)}if(this.arConfig.forceSyntax&&{php:1,js:1,css:1,sql:1}[this.arConfig.forceSyntax]){this.syntaxName=this.arConfig.forceSyntax}else{this.syntaxName="php";this.arConfig.forceSyntax=false}this.InitKeyEngine();this.BuildSceleton();if(BX.browser.IsIOS())this.pInput.style.width="0px";if(!BX.browser.IsSafari()&&!BX.browser.IsChrome())this.pScroller.draggable=true;this.pLinesCont.style.outline="none";this.FocusInput();if(BX.browser.IsMac()){this.pScrollbar.style.zIndex=-2;this.pScrollbar.style.visibility="hidden"}else if(BX.browser.IsIE()&&!BX.browser.IsIE9()){this.pScrollbar.style.minWidth="18px"}try{this.GetCharWidth()}catch(t){return}this.pollDelayed=new c;this.highlight=new c;this.oDoc=new r([new s([new e("")])]);this.focused=false;this.LoadSyntax();this.oSel={from:{line:0,ch:0},to:{line:0,ch:0},inverted:false};this.lastClick=false;this.lastDoubleClick=false;this._lastScrollTop=0;this._lastStoppedKey=null;this.suppressEdits=false;this.callbacks=null;this.arChanges=[];this.displayOffset=0;this.showingFrom=0;this.showingTo=0;this.lastSizeC=0;this.bracketHighlighted=null;this.maxLine=this.GetLine(0);this.updateMaxLine=false;this.maxLineChanged=true;this._tabCache={};this.pollingFast=false;this.goalColumn=null;this.Action(this.SetValue,this)(this.pTA.value||"");this.updateInput=false;this.oHistory=new h;BX.bind(this.pScroller,"mousedown",this.Action(this.OnMouseDown,this));BX.bind(this.pScroller,"dblclick",this.Action(this.OnDoubleClick,this));BX.bind(this.pLinesCont,"selectstart",BX.PreventDefault);BX.bind(this.pScroller,"scroll",BX.proxy(this.OnScrollMain,this));BX.bind(this.pScrollbar,"scroll",BX.proxy(this.OnScrollBar,this));BX.bind(this.pScrollbar,"mousedown",function(){if(t.highlightMode&&t.focused)setTimeout(t.FocusInput,0)});BX.bind(this.pInput,"keyup",this.Action(this.OnKeyUp,this));BX.bind(this.pInput,"input",BX.proxy(this.FastPoll,this));BX.bind(this.pInput,"keydown",this.Action(this.OnKeyDown,this));BX.bind(this.pInput,"keypress",this.Action(this.OnKeyPress,this));BX.bind(this.pInput,"focus",BX.proxy(this.OnFocus,this));BX.bind(this.pInput,"blur",BX.proxy(this.OnBlur,this));BX.bind(this.pScroller,"paste",function(){t.FocusInput();t.FastPoll()});BX.bind(this.pInput,"paste",BX.proxy(this.FastPoll,this));BX.bind(this.pInput,"cut",this.Action(function(){t.ReplaceSelection("")},this));setTimeout(BX.proxy(this.OnFocus,this),20);if(this.theme!="dark"){this.theme="dark";this.SwitchTheme()}if(!this.highlightMode){this.highlightMode=true;this.SwitchHightlightMode()}var i=this.pTA.form;if(i){BX.addCustomEvent(i,"onAutoSavePrepare",function(){if(i&&i.BXAUTOSAVE){try{BX.addCustomEvent(this,"OnAfterActionSelectionChanged",function(){i.BXAUTOSAVE.Init()});BX.addCustomEvent(i,"onAutoSave",function(e,i){if(t.highlightMode)t.Save();i[t.pTA.name]=t.GetTAValue()});BX.addCustomEvent(i,"onAutoSaveRestore",function(e,i){if(t.highlightMode){t.Action(t.SetValue,t)(i[t.pTA.name])}else{t.pTA.value=i[t.pTA.name];t.CheckLineSelection()}})}catch(t){}}});BX.bind(i,"reset",function(){if(t.highlightMode){t.Action(t.SetValue,t)("");t.FocusInput();t.OnFocus()}})}},BuildSceleton:function(){var t=this;this.pDiv=this.pTA.parentNode.appendChild(BX.create("DIV",{props:{className:"bxce bxce-hls"}}));this.pWarning=this.pDiv.appendChild(BX.create("DIV",{props:{className:"bxce-warning-cont"},text:this.MESS.HighlightWrongwarning,style:{display:"none"}}));this.pInnerContHL=this.pDiv.appendChild(BX.create("DIV",{props:{className:"bxce-inner-hl"}}));this.pBaseContTA=this.pDiv.appendChild(BX.create("DIV",{props:{className:"bxce-base-cont"},style:{display:"none"}}));this.pBaseContTA.onclick=function(e){BX.focus(t.pTA)};this.pContTA=this.pBaseContTA.appendChild(BX.create("DIV",{props:{className:"bxce-cont"}}));this.pLineNumTABgTA=this.pBaseContTA.appendChild(BX.create("DIV",{props:{className:"bxce-line-num-bg"}}));this.pLineNumTA=this.pContTA.appendChild(BX.create("DIV",{props:{className:"bxce-line-num bxce-font"}}));this.pContTA.appendChild(this.pTA);this.pTA.className="bxce-ta";this.pTA.style.display="none";this.pTA.removeAttribute("cols");this.pTA.removeAttribute("rows");this.pTA.setAttribute("spellcheck",false);this.pTA.setAttribute("hidefocus",true);this.pTA.setAttribute("autocomplete","off");this.pTA.setAttribute("autocorrect","off");this.pTA.setAttribute("autocapitalize","off");this.pTA.setAttribute("wrap","off");this.pTA.onkeyup=BX.proxy(this.TextOnKeyup,this);this.pTA.onkeydown=BX.proxy(this.TextOnKeydown,this);this.pTA.onmousedown=BX.proxy(this.TextOnMousedown,this);this.pInputCont=this.pInnerContHL.appendChild(BX.create("DIV",{props:{className:"bxce-inp-cont"}}));this.pInput=this.pInputCont.appendChild(BX.create("TEXTAREA",{props:{className:"bxce-inp"}}));this.pInput.setAttribute("wrap","off");this.pInput.setAttribute("autocorrect","off");this.pInput.setAttribute("autocapitalize","off");this.pScrollbar=this.pInnerContHL.appendChild(BX.create("DIV",{props:{className:"bxce-scrollbar"}}));this.pScrollbarInner=this.pScrollbar.appendChild(BX.create("DIV",{props:{className:"bxce-scrollbar-inner"}}));this.pScroller=this.pInnerContHL.appendChild(BX.create("DIV",{props:{className:"bxce-scroller",tabIndex:-1}}));this.pSizeCont=this.pScroller.appendChild(BX.create("DIV",{props:{className:"bxce-size-cont",tabIndex:-1}}));this.pMover=this.pSizeCont.appendChild(BX.create("DIV",{props:{className:"bxce-inner-size-cont"}}));this.pLineNum=this.pMover.appendChild(BX.create("DIV",{props:{className:"bxce-hl-line-num"}}));this.pLineNumText=this.pLineNum.appendChild(BX.create("DIV",{props:{className:"bxce-hl-line-num-text"}}));this.pHighlight=this.pMover.appendChild(BX.create("DIV",{props:{className:"bxce-highlight"}}));this.pLinesCont=this.pHighlight.appendChild(BX.create("DIV",{props:{className:"bxce-lines-cnt"}}));this.pMeasure=this.pLinesCont.appendChild(BX.create("DIV",{props:{className:"bxce-liner-cont"}}));this.pCursor=this.pLinesCont.appendChild(BX.create("PRE",{props:{className:"bxce-cursor"},text:"\xa0"}));this.pWidthForcer=this.pLinesCont.appendChild(BX.create("PRE",{props:{className:"bxce-cursor"},style:{visibility:"hidden"},text:"\xa0"}));this.pSelectionDiv=this.pLinesCont.appendChild(BX.create("DIV",{props:{className:"bxce-sel-cont"}}));this.pLineDiv=this.pLinesCont.appendChild(BX.create("DIV"));this.pFootCont=this.pDiv.appendChild(BX.create("DIV",{props:{className:"bxce-foot-cont"}}));this.pFastLineInp=this.pFootCont.appendChild(BX.create("SPAN",{props:{className:"bxce-go-to-line-cont"}})).appendChild(BX.create("INPUT",{props:{className:"bxce-go-to-line",title:this.MESS.GoToLine}}));this.pFastLineInp.onfocus=function(){setTimeout(function(){t.pFastLineInp.select()},10)};this.pFootCont.onclick=function(){setTimeout(function(){t.pFastLineInp.select()},10)};this.pFastLineInp.onkeydown=BX.proxy(this.FastGoToLine,this);this.pCurPosCont=this.pFootCont.appendChild(BX.create("SPAN",{props:{className:"bxce-info-cur-cont"},html:this.MESS.Line+":"}));this.pInfoCurLine=this.pCurPosCont.appendChild(BX.create("SPAN",{props:{className:"bxce-info-cur-line",title:this.MESS.LineTitle}}));this.pCurPosCont.appendChild(document.createTextNode(this.MESS.Char+":"));this.pInfoCurChar=this.pCurPosCont.appendChild(BX.create("SPAN",{props:{className:"bxce-info-cur-char",title:this.MESS.CharTitle}}));this.pTotalCont=this.pFootCont.appendChild(BX.create("SPAN",{props:{className:"bxce-info-total-cont"},html:this.MESS.Total+"  "+this.MESS.Lines+":"}));this.pInfoTotLines=this.pTotalCont.appendChild(BX.create("SPAN",{props:{className:"bxce-info-total-line"}}));this.pModeToggle=this.pFootCont.appendChild(BX.create("A",{props:{href:"javascript:void(0)",className:"bxce-mode-link"+(this.highlightMode?" bxce-mode-link-on":""),title:this.MESS.EnableHighlightTitle},html:'<span class="bxce-mode-txt">'+this.MESS.EnableHighlight+"</span><i></i>"}));this.pModeToggle.onclick=BX.proxy(this.SwitchHightlightMode,this);this.pThemeToggle=this.pFootCont.appendChild(BX.create("A",{props:{href:"javascript:void(0)",className:"bxce-theme-toggle"},html:'<i></i><span class="bxce-theme-toggle-text">'+this.MESS.LightTheme+"</span>"}));this.pThemeToggle.onclick=BX.proxy(this.SwitchTheme,this);this.pThemeToggleText=this.pThemeToggle.childNodes[1];this.AdjustSceletonSize()},Action:function(t,e){var i=this;if(e==undefined)e=this;return function(){if(!i.actionCount++)i.OnBeforeAction();try{var n=t.apply(e,arguments)}finally{if(!--i.actionCount)i.OnAfterAction()}return n}},OnBeforeAction:function(){BX.onCustomEvent(this,"OnBeforeAction");this.updateInput=null;this.userSelChange=null;this.textChanged=null;this.changes=[];this.arChanges=[];this.selectionChanged=false;this.callbacks=[]},OnAfterAction:function(){if(this.updateMaxLine)this.ComputeMaxLength();if(this.maxLineChanged){var t=this.pWidthForcer.offsetWidth,e=this.MeasureLine(this.maxLine,this.maxLine.text.length).left;if(!BX.browser.IsIE()||BX.browser.IsIE9()){this.pWidthForcer.style.left=e+"px";this.pLinesCont.style.minWidth=e+t+"px"}this.maxLineChanged=false}var i,n;if(this.selectionChanged){var s=this.CalculateCursorCoords();i=this.CalculateScrollPos(s.x,s.y,s.x,s.yBot)}if(this.arChanges.length||i&&i.scrollTop!=null)n=this.UpdateDisplay(this.arChanges,true,i&&i.scrollTop);if(!n){if(this.selectionChanged)this.UpdateSelection();if(this.lineNumDirty)this.UpdateLineNum()}if(i)this.ScrollCursorIntoView();if(this.selectionChanged)this.RestartBlink();if(this.focused&&(this.updateInput===true||this.updateInput!==false&&this.selectionChanged))this.ResetInput(this.userSelChange);if(this.selectionChanged){BX.onCustomEvent(this,"OnAfterActionSelectionChanged");setTimeout(this.Action(this.CheckMatchingBrackets,this),20)}this.SetStatusBarInfo(this.oSel.to);BX.onCustomEvent(this,"OnAfterAction")},CheckMatchingBrackets:function(){if(this.bracketHighlighted){this.bracketHighlighted();this.bracketHighlighted=null}if(this.PosEq(this.oSel.from,this.oSel.to))this.MatchBrackets()},MatchBrackets:function(){var t,e=this.oSel.inverted?this.oSel.from:this.oSel.to,i=this.GetLine(e.line),n=e.ch-1;var s=n>=0&&this.arBrackets[i.text.charAt(n)]||this.arBrackets[i.text.charAt(++n)];if(!s)return;var r=this,o,l,h=s.charAt(0),a=s.charAt(1)==">",c=a?1:-1,u=i.styles;for(o=n+1,l=0;l<u.length;l+=2){if((o-=u[l].length)<=0){t=u[l+1];break}}var f=[i.text.charAt(n)],p=/[(){}[\]]/;function d(e,i,n){if(!e.text)return;var s=e.styles,o=a?0:e.text.length-1,l;for(var h=a?0:s.length-2,u=a?s.length:-2;h!=u;h+=2*c){var d=s[h];if(s[h+1]!=t){o+=c*d.length;continue}for(var g=a?0:d.length-1,m=a?d.length:-1;g!=m;g+=c,o+=c){if(o>=i&&o<n&&p.test(l=d.charAt(g))){var S=r.arBrackets[l];if(S.charAt(1)==">"==a)f.push(l);else if(f.pop()!=S.charAt(0))return{pos:o,match:false};else if(!f.length)return{pos:o,match:true}}}}}var g,m,S;for(l=e.line,g=a?Math.min(l+100,this.oDoc.size):Math.max(-1,l-100);l!=g;l+=c){i=this.GetLine(l);m=l==e.line;S=d(i,m&&a?n+1:0,m&&!a?n:i.text.length);if(S)break}if(!S)S={pos:null,match:false};var v=S.match?"bxce-hl-bracket":"bxce-non-hl-bracket",x=this.HightlightFrag({line:e.line,ch:n},{line:e.line,ch:n+1},v),C=S.pos!=null&&this.HightlightFrag({line:l,ch:S.pos},{line:l,ch:S.pos+1},v);this.bracketHighlighted=this.Action(function(){x.Clear();if(C)C.Clear()},this)},SetStatusBarInfo:function(t){if(this.highlightMode||t.nbLine==undefined){this.pInfoCurLine.innerHTML=t.line+1;this.pInfoCurChar.innerHTML=t.ch;this.pInfoTotLines.innerHTML=this.oDoc.size;this.pFastLineInp.value=t.line+1}else{this.pInfoCurLine.innerHTML=t.linePos;this.pInfoCurChar.innerHTML=t.carretPos;this.pInfoTotLines.innerHTML=t.nbLine;this.pFastLineInp.value=t.linePos}},FastGoToLine:function(t){if(!t)t=window.event;var e=t.which||t.keyCode;if(e==13){this.GoToLine(this.pFastLineInp.value);return BX.PreventDefault(t)}},GoToLine:function(t){t=parseInt(t,10);if(isNaN(t))return;if(this.highlightMode){t--;if(t<0)t=0;if(t>=this.oDoc.size)t=this.oDoc.size-1;this.OnBeforeAction();this.SetCursor(t,0,true);this.OnAfterAction();setTimeout(BX.proxy(this.FocusInput,this),20)}else{if(t<0)t=0;var e=0,i,n=BX.browser.IsIE()?0:1,s=this.GetTAValue(),r=s.split("\n"),o=r.length;if(t>o){e=s.length}else{for(i=0;i<t-1;i++)e+=r[i].length+n}this.SelectTA(e,0);this.MoveLineSelection();if(BX.browser.IsChrome()||BX.browser.IsSafari()){if(this.pLineNumTA.childNodes[t-1])this.pLineNumTA.childNodes[t-1].scrollIntoView(false)}return e}},SelectTA:function(t,e){BX.focus(this.pTA);var i=this.pTA.value.length;if(t<0)t=0;if(t>i)t=i;var n=t+e;if(n>i)n=i;if(BX.browser.IsIE())this.SetIETASelection(t,n);else this.pTA.setSelectionRange(t,n)},SetIETASelection:function(t,e){var i=this.GetTAValue().replace(/\r/g,""),n=i.substr(0,t).split("\n").length-1,s=i.substr(0,e).split("\n").length-1,r=document.selection.createRange();t+=n;e+=s;r.moveToElementText(this.pTA);r.setEndPoint("EndToStart",r);r.moveStart("character",t-n);r.moveEnd("character",e-s-(t-n));r.select()},MoveLineSelection:function(t){if(this.checkLineTimeout)this.checkLineTimeout=clearTimeout(this.checkLineTimeout);if(t===true)this.checkLineTimeout=setTimeout(BX.proxy(this.MoveLineSelection,this),5);else this.CheckLineSelection(false)},SwitchTheme:function(){if(this.theme=="dark"){this.theme="light";BX.addClass(this.pDiv,"bxce--light");this.pThemeToggleText.innerHTML=this.MESS.DarkTheme}else{BX.removeClass(this.pDiv,"bxce--light");this.theme="dark";this.pThemeToggleText.innerHTML=this.MESS.LightTheme}if(this.highlightMode){if(!this.focused){this.FocusInput();this.OnFocus()}}else{BX.focus(this.pTA)}this.SaveUserOption("theme",this.theme)},SwitchHightlightMode:function(){this.highlightMode=!this.highlightMode;if(this.__warnTimeout)this.__warnTimeout=clearTimeout(this.__warnTimeout);if(this.highlightMode&&!this.IsValidBrowser()){var t=this;this.pWarning.style.display="";this.__warnTimeout=setTimeout(function(){t.pWarning.style.display="none"},4e3)}else{this.pWarning.style.display="none"}if(this.highlightMode){this.pInnerContHL.style.display="";this.pBaseContTA.style.display="none";this.pTA.style.display="none";BX.addClass(this.pModeToggle,"bxce-mode-link-on");BX.addClass(this.pDiv,"bxce-hls");if(!BX.browser.IsSafari()&&!BX.browser.IsChrome())this.pScroller.setAttribute("draggable",true);this.Action(this.SetValue,this)(this.pTA.value||"");if(!this.focused){this.FocusInput();this.OnFocus()}}else{this.Save();var e=this.pHighlight.offsetWidth-60,i=this.pHighlight.offsetHeight;this.pTA.style.width=e+"px";this.pContTA.style.width=e+"px";this.pTA.style.height=i+"px";this.pInnerContHL.style.display="none";this.pTA.style.display="";this.pBaseContTA.style.display="";BX.focus(this.pTA);setTimeout(BX.proxy(this.ManageSize,this),100);BX.removeClass(this.pModeToggle,"bxce-mode-link-on");BX.removeClass(this.pDiv,"bxce-hls");if(!BX.browser.IsSafari()&&!BX.browser.IsChrome())this.pScroller.removeAttribute("draggable")}this.SaveUserOption("highlight",this.highlightMode?1:0)},IsValidBrowser:function(){return!BX.browser.IsIE()||BX.browser.IsDoctype()},SaveUserOption:function(t,e){if(this.saveSettings)BX.userOptions.save("fileman","code_editor",t,e)},SetValue:function(t){var e={line:0,ch:0};this.UpdateLines(e,{line:this.oDoc.size-1,ch:this.GetLine(this.oDoc.size-1).text.length},this.ExplodeLines(t),e,e);this.updateInput=true},GetValue:function(t){var e=[];this.oDoc.Iteration(0,this.oDoc.size,function(t){e.push(t.text)});return e.join(t||"\n")},GetTAValue:function(){return this.pTA.value},SetTAValue:function(t){if(t==undefined)t=this.GetTAValue();else t=t.replace(/\r/g,"");this.pTA.value=t},Save:function(){this.pTA.value=this.GetValue()},AdjustSceletonSize:function(t,e){var i=this,n=t,s=e;if(!t||!e||t<=0||e<=0){if(this.arConfig.width)t=parseInt(this.arConfig.width);if(this.arConfig.height)e=parseInt(this.arConfig.height);if(this.pDiv.parentNode&&!t)t=parseInt(this.pDiv.parentNode.offsetWidth)-(BX.browser.IsIE()?10:2);if(this.pDiv.parentNode&&!e)e=parseInt(this.pDiv.parentNode.offsetHeight)-2;if(!t||isNaN(t)||e<100)t=900;if(!e||isNaN(e)||e<100)e=400}if(t<=0||e<=0){return setTimeout(function(){i.AdjustSceletonSize(n,s)},300)}t=parseInt(t);e=parseInt(e);var r=t,o=20,l=e-o;this.pScroller.style.height=l+"px";this.pLineNumTABgTA.style.height=l+"px";this.pBaseContTA.style.height=l+"px";this.pBaseContTA.style.width=r+"px";this.pDiv.style.width=t+"px";this.pDiv.style.height=e+"px"},Resize:function(t,e){t=parseInt(t);e=parseInt(e);this.AdjustSceletonSize(t,e);this.UpdateDisplay(true);if(BX.browser.IsChrome()){var i=this;setTimeout(function(){i.UpdateDisplay(true)},300)}},HasSelection:window.getSelection?function(t){var e=false;try{e=t.selectionStart!=t.selectionEnd}catch(t){}return e}:function(t){var e=false;try{e=t.ownerDocument.selection.createRange()}catch(t){}if(!e||e.parentElement()!=t)e=false;else if(e)e=e.compareEndPoints("StartToEnd",e)!=0;return e},ExplodeLines:"\n\nb".split(/\n/).length==3?function(t){return t.split(/\r\n?|\n/)}:function(t){var e,i,n,s=0,r=[],o=t.length;while(s<=o){e=t.indexOf("\n",s);if(e==-1)e=t.length;i=t.slice(s,t.charAt(e-1)=="\r"?e-1:e);n=i.indexOf("\r");if(n!=-1){r.push(i.slice(0,n));s+=n+1}else{r.push(i);s=e+1}}return r},HightlightFrag:function(t,e,i){t=this.ClipPos(t);e=this.ClipPos(e);var n=this;var s=this.GetHighlighter();if(!this.PosLess(t,e))return s;function r(t,e,i,r){n.GetLine(t).addMark(new v(e,i,r,s))}if(t.line==e.line){r(t.line,t.ch,e.ch,i)}else{r(t.line,t.ch,null,i);for(var o=t.line+1,l=e.line;o<l;++o)r(o,null,null,i);r(e.line,null,e.ch,i)}this.arChanges.push({from:t.line,to:e.line+1});return s},GetHighlighter:function(){var t={set:[]};t.Clear=this.Action(function(){var e,i,n,s,r=Infinity,l=-Infinity;for(e=0;e<t.set.length;++e){i=t.set[e];if(!i.marked||!i.parent)continue;s=o(i);r=Math.min(r,s);l=Math.max(l,s);i.marked=[]}if(r!=Infinity)this.arChanges.push({from:r,to:l+1})},this);return t},GetCursor:function(t){if(t==undefined)t=this.oSel.inverted;return this.CopyPos(t?this.oSel.from:this.oSel.to)},SetCursor:function(t,e,i){var n=this.ClipPos({line:t,ch:e||0});if(i)this.SetSelectionUser(n,n);else this.SetSelection(n,n)},ClipLine:function(t){return Math.max(0,Math.min(t,this.oDoc.size-1))},ClipPos:function(t){var e=t;if(t.line<0){e={line:0,ch:0}}else if(t.line>=this.oDoc.size){e={line:this.oDoc.size-1,ch:this.GetLine(_this.oDoc.size-1).text.length}}else{var i=t.ch,n=this.GetLine(t.line).text.length;if(i==null||i>n)e={line:t.line,ch:n};else if(i<0)e={line:t.line,ch:0}}return e},GetLine:function(t){return this.GetLineAt(this.oDoc,t)},GetLineAt:function(t,e){while(!t.lines){var i,n,s;for(i=0;;++i){n=t.children[i];if(!n||!n.GetSize)break;s=n.GetSize();if(e<s){t=n;break}e-=s}}return t.lines[e]},InitSyntax:function(t,e){if(arguments.length>2){this.arSyntaxControl=[];for(var i=2;i<arguments.length;++i)this.arSyntaxControl.push(arguments[i])}this.arSyntaxes[t]=e},LoadSyntax:function(){this.oSyntax=g[this.syntaxName](!!this.arConfig.forceSyntax);this.oDoc.Iteration(0,this.oDoc.size,function(t){t.statusAfter=null});this.work=[0];this.StartWorker()},StartWorker:function(t){if(!this.work.length)return;this.highlight.set(t,this.Action(this.HighlightWorker))},HighlightWorker:function(){var t=this,e,i,n,s,r,o,l,h,a=+new Date+this.timeout;while(this.work.length){e=this.GetLine(this.showingFrom).statusAfter?this.work.pop():this.showingFrom;if(e>=this.oDoc.size)continue;i=this.FindStartLine(e);n=i&&this.GetLine(i-1).statusAfter;if(n)n=this.OnSyntaxCopyState(this.oSyntax,n);else n=this.OnSyntaxStartState(this.oSyntax);s=0;r=this.oSyntax.compareStates;o=false;l=i;h=false;this.oDoc.Iteration(l,this.oDoc.size,function(i){var c=i.statusAfter;if(+new Date>a){t.work.push(l);t.StartWorker(t.delay);if(o)t.arChanges.push({from:e,to:l+1});return h=true}var u=i.highlight(t.oSyntax,n,t.tabSize);if(u)o=true;i.statusAfter=t.OnSyntaxCopyState(t.oSyntax,n);var f=null;if(r){var p=c&&r(c,n);f=!!p}if(f==null){if(u!==false||!c)s=0;else if(++s>3&&(!t.oSyntax.Indent||t.oSyntax.Indent(c,"")==t.oSyntax.Indent(n,"")))f=true}if(f)return true;l++});if(h)return;if(o)this.arChanges.push({from:e,to:l+1})}},OnSyntaxStartState:function(t,e,i){return t.startStatus?t.startStatus(e,i):true},OnSyntaxCopyState:function(t,e){if(e===true)return e;if(t.copyStatus)return t.copyStatus(e);var i={};for(var n in e){var s=e[n];if(s instanceof Array)s=s.concat([]);i[n]=s}return i},FindStartLine:function(t){var e,i,n,s=t-40;for(n=t;n>s;--n){if(n==0)return 0;var r=this.GetLine(n-1);if(r.statusAfter)return n;var o=r.indentation(this.tabSize);if(i==null||e>o){i=n-1;e=o}}return i},GetStateBefore:function(t){var e=this.FindStartLine(t),i=e&&this.GetLine(e-1).statusAfter;if(i)i=this.OnSyntaxCopyState(this.oSyntax,i);else i=this.OnSyntaxStartState(this.oSyntax);this.oDoc.Iteration(e,t,function(t){t.highlight(_this.oSyntax,i,_this.tabSize);t.statusAfter=_this.OnSyntaxCopyState(_this.oSyntax,i)});if(e<t)this.arChanges.push({from:e,to:t});if(t<this.oDoc.size&&!this.GetLine(t).statusAfter)this.work.push(t);return i},UpdateDisplay:function(t,e,i){if(!this.pScroller.clientWidth){this.showingFrom=this.showingTo=this.displayOffset=0;return}var n=this.VisibleLines(i);if(t!==true&&t.length==0&&n.from>this.showingFrom&&n.to<this.showingTo)return this.UpdateVerticalScroll(i);var s=Math.max(n.from-100,0),r=Math.min(this.oDoc.size,n.to+100);if(this.showingFrom<s&&s-this.showingFrom<20)s=this.showingFrom;if(this.showingTo>r&&this.showingTo-r<20)r=Math.min(this.oDoc.size,this.showingTo);var o=t===true?[]:this.GetUnchanged([{from:this.showingFrom,to:this.showingTo,domStart:0}],t);var l=0;for(var h=0;h<o.length;++h){var a=o[h];if(a.from<s){a.domStart+=s-a.from;a.from=s}if(a.to>r)a.to=r;if(a.from>=a.to)o.splice(h--,1);else l+=a.to-a.from}if(l==r-s&&s==this.showingFrom&&r==this.showingTo)return this.UpdateVerticalScroll(i);o.sort(function(t,e){return t.domStart-e.domStart});var c=this.TextHeight(),u=this.pLineNum.style.display;this.pLineDiv.style.display="none";this.PatchDisplay(s,r,o);this.pLineDiv.style.display=this.pLineNum.style.display="";var f=s!=this.showingFrom||r!=this.showingTo||this.lastSizeC!=this.pScroller.clientHeight+c;if(f)this.lastSizeC=this.pScroller.clientHeight+c;this.showingFrom=s;this.showingTo=r;this.displayOffset=this.HeightAtLine(this.oDoc,s);if(this.pLineDiv.childNodes.length!=this.showingTo-this.showingFrom){throw new Error("BAD PATCH! "+JSON.stringify(o)+" size="+(this.showingTo-this.showingFrom)+" nodes="+this.pLineDiv.childNodes.length)}this.pLineNum.style.display=u;if(f||this.lineNumDirty)this.UpdateLineNum();this.UpdateVerticalScroll(i);this.UpdateSelection();return true},VisibleLines:function(t){var e=this.TextHeight(),i=(t!=null?t:this.pScrollbar.scrollTop)-this.PaddingTop();return{from:this.LineAtHeight(this.oDoc,Math.max(0,Math.floor(i/e))),to:this.LineAtHeight(this.oDoc,Math.ceil((i+this.pScroller.clientHeight)/e))}},TextHeight:function(){var t=50;if(!this._measurePre){this._measurePre=BX.create("PRE");for(var e=0;e<t;++e){this._measurePre.appendChild(document.createTextNode("W"));if(e<t-1)this._measurePre.appendChild(BX.create("br"))}}var i=this.pLineDiv.clientHeight;if(i!=this._cachedHeightFor){this._cachedHeightFor=i;BX.cleanNode(this.pMeasure);this.pMeasure.appendChild(this._measurePre.cloneNode(true));this._cachedHeight=this.pMeasure.firstChild.offsetHeight/t||1;BX.cleanNode(this.pMeasure)}return this._cachedHeight},UpdateLinesNoUndo:function(t,i,n,s,r){if(this.suppressEdits)return;var o,l=this,h=false,a=this.maxLine.text.length;this.oDoc.Iteration(t.line,i.line+1,function(t){if(!t.hidden&&t.text.length==a){h=true;return true}});if(t.line!=i.line||n.length>1)this.lineNumDirty=true;var c=i.line-t.line,u=this.GetLine(t.line),f=this.GetLine(i.line);if(t.ch==0&&i.ch==0&&n[n.length-1]==""){o=[];var p=null;if(t.line){p=this.GetLine(t.line-1);p.fixMarkEnds(f)}else{f.fixMarkStarts()}for(var d=0,g=n.length-1;d<g;++d)o.push(e.inheritMarks(n[d],p));if(c)this.oDoc.Remove(t.line,c,this.callbacks);if(o.length)this.oDoc.Insert(t.line,o)}else if(u==f){if(n.length==1){u.Replace(t.ch,i.ch,n[0])}else{f=u.split(i.ch,n[n.length-1]);u.Replace(t.ch,null,n[0]);u.fixMarkEnds(f);o=[];for(var d=1,g=n.length-1;d<g;++d)o.push(e.inheritMarks(n[d],u));o.push(f);this.oDoc.Insert(t.line+1,o)}}else if(n.length==1){u.Replace(t.ch,null,n[0]);f.Replace(null,i.ch,"");u.append(f);this.oDoc.Remove(t.line+1,c,this.callbacks)}else{o=[];u.Replace(t.ch,null,n[0]);f.Replace(null,i.ch,n[n.length-1]);u.fixMarkEnds(f);for(var d=1,g=n.length-1;d<g;++d)o.push(e.inheritMarks(n[d],u));if(c>1)this.oDoc.Remove(t.line+1,c-1,this.callbacks);this.oDoc.Insert(t.line+1,o)}this.oDoc.Iteration(t.line,t.line+n.length,function(t){var e=t.text;if(!t.hidden&&e.length>a){l.maxLine=t;a=e.length;l.maxLineChanged=true;h=false}});if(h)this.updateMaxLine=true;var m=[],S=n.length-c-1;for(var d=0,v=l.work.length;d<v;++d){var x=l.work[d];if(x<t.line)m.push(x);else if(x>i.line)m.push(x+S)}var C=t.line+Math.min(n.length,500);this.HighlightLines(t.line,C);m.push(C);this.work=m;this.StartWorker(100);this.arChanges.push({from:t.line,to:i.line+1,diff:S});var y={from:t,to:i,text:n};if(this.textChanged){for(var b=this.textChanged;b.next;b=b.next){}b.next=y}else{this.textChanged=y}function T(t){return t<=Math.min(i.line,i.line+S)?t:t+S}this.SetSelection(this.ClipPos(s),this.ClipPos(r),T(this.oSel.from.line),T(this.oSel.to.line))},UpdateLines:function(t,e,i,n,s){if(this.suppressEdits)return;if(this.oHistory){var r=[];this.oDoc.Iteration(t.line,e.line+1,function(t){r.push(t.text)});this.oHistory.addChange(t.line,i.length,r);while(this.oHistory.done.length>this.undoDepth)this.oHistory.done.shift()}this.UpdateLinesNoUndo(t,e,i,n,s)},HighlightLines:function(t,e){var i=this,n=this.GetStateBefore(t);this.oDoc.Iteration(t,e,function(t){t.highlight(i.oSyntax,n,i.tabSize);t.statusAfter=i.OnSyntaxCopyState(i.oSyntax,n)})},SetSelectionUser:function(t,e){var i=this.shiftSelecting&&this.ClipPos(this.shiftSelecting);if(i){if(this.PosLess(i,t))t=i;else if(this.PosLess(e,i))e=i}this.SetSelection(t,e);this.userSelChange=true},SetSelection:function(t,e,i,n){this.goalColumn=null;if(i==null){i=this.oSel.from.line;n=this.oSel.to.line}if(this.PosEq(this.oSel.from,t)&&this.PosEq(this.oSel.to,e))return;if(this.PosLess(e,t)){var s=e;e=t;t=s}if(t.line!=i){var r=this.SkipHidden(t,i,this.oSel.from.ch);if(!r)this.SetLineHidden(t.line,false);else t=r}if(e.line!=n)e=this.SkipHidden(e,n,this.oSel.to.ch);if(this.PosEq(t,e)||this.PosEq(t,this.oSel.to))this.oSel.inverted=false;else if(this.PosEq(e,this.oSel.from))this.oSel.inverted=true;if(this.PosEq(this.oSel.from,this.oSel.to)){var l=this.oSel.inverted?t:e;if(l.line!=this.oSel.from.line&&this.oSel.from.line<this.oDoc.size){var h=this.GetLine(this.oSel.from.line);if(/^\s+$/.test(h.text)){setTimeout(this.Action(function(){if(h.parent&&/^\s+$/.test(h.text)){var t=o(h);this.ReplaceRange("",{line:t,ch:0},{line:t,ch:h.text.length})}},this),10)}}}this.oSel.from=t;this.oSel.to=e;this.selectionChanged=true},PosEq:function(t,e){return t.line==e.line&&t.ch==e.ch},PosLess:function(t,e){return t.line<e.line||t.line==e.line&&t.ch<e.ch},CopyPos:function(t){return{line:t.line,ch:t.ch}},GetCharWidth:function(){if(this.pScroller.clientWidth==this._cachedWidthFor)return this._cachedWidth;this._cachedWidthFor=this.pScroller.clientWidth;var t=BX.create("SPAN",{text:" x"});BX.cleanNode(this.pMeasure);this.pMeasure.appendChild(BX.create("PRE",{children:[t]}));this._cachedWidth=t.offsetWidth||10;return this._cachedWidth},RestartBlink:function(){if(this._blinkerInterval)this._blinkerInterval=clearInterval(this._blinkerInterval);var t=this.pCursor,e=true;t.style.visibility="";this._blinkerInterval=setInterval(function(){t.style.visibility=(e=!e)?"":"hidden"},this.cursorInterval)},ReadInput:function(){if(!this.focused||this.HasSelection(this.pInput))return false;var t=this.pInput.value;if(t==this.prevInput)return false;this.shiftSelecting=null;var e=0,i=Math.min(this.prevInput.length,t.length);while(e<i&&this.prevInput[e]==t[e])++e;if(e<this.prevInput.length)this.oSel.from={line:this.oSel.from.line,ch:this.oSel.from.ch-(this.prevInput.length-e)};this.ReplaceSelection(t.slice(e),"end");if(t.length>1e3)this.pInput.value=this.prevInput="";else this.prevInput=t;return true},ResetInput:function(t){if(!this.PosEq(this.oSel.from,this.oSel.to)){this.prevInput="";this.pInput.value=this.GetSelection();if(this.focused){if(BX.browser.IsIOS()){this.pInput.selectionStart=0;this.pInput.selectionEnd=this.pInput.value.length}else{this.pInput.select()}}}else if(t){this.prevInput=this.pInput.value=""}},FocusInput:function(){BX.focus(this.pInput)},SetShift:function(t){if(t)this.shiftSelecting=this.shiftSelecting||(this.oSel.inverted?this.oSel.to:this.oSel.from);else this.shiftSelecting=null},MakeTab:function(t){var e,n=this.tabSize-t%this.tabSize;if(this._tabCache[n])return this._tabCache[n];for(e="",i=0;i<n;++i)e+=" ";this._tabCache[n]={element:BX.create("TT",{text:e,props:{className:"bxce-tabspan"}}),width:n};return this._tabCache[n]},ComputeMaxLength:function(){this.maxLine=this.GetLine(0);this.maxLineChanged=true;var t=this,e=this.maxLine.text.length;this.oDoc.Iteration(1,this.oDoc.size,function(i){var n=i.text;if(!i.hidden&&n.length>e){e=n.length;t.maxLine=i}});this.updateMaxLine=false},MeasureLine:function(t,e){if(e==0)return{top:0,left:0};var i=t.getElement(BX.proxy(this.MakeTab,this),e,false);BX.cleanNode(this.pMeasure);this.pMeasure.appendChild(i);var n=i.anchor,s=n.offsetTop,r=n.offsetLeft;return{top:s,left:r}},ScrollCursorIntoView:function(){var t=this.CalculateCursorCoords();this.ScrollIntoView(t.x,t.y,t.x,t.yBot);if(!this.focused)return;var e=this.pSizeCont.getBoundingClientRect(),i=null;if(t.y+e.top<0)i=true;else if(t.y+e.top+this.TextHeight()>(window.innerHeight||document.documentElement.clientHeight))i=false;if(i!=null){var n=this.pCursor.style.display=="none";if(n){this.pCursor.style.display="";this.pCursor.style.left=t.x+"px";this.pCursor.style.top=t.y-this.displayOffset+"px"}this.pCursor.scrollIntoView(i);if(n)this.pCursor.style.display="none"}},CalculateCursorCoords:function(){var t=this.LocalCoords(this.oSel.inverted?this.oSel.from:this.oSel.to);return{x:t.x,y:t.y,yBot:t.yBot}},ScrollIntoView:function(t,e,i,n){var s=this.CalculateScrollPos(t,e,i,n);if(s.scrollLeft!=null)this.pScroller.scrollLeft=s.scrollLeft;if(s.scrollTop!=null)this.pScrollbar.scrollTop=this.pScroller.scrollTop=s.scrollTop},CalculateScrollPos:function(t,e,i,n){var s=this.PaddingLeft(),r=this.PaddingTop();e+=r;n+=r;t+=s;i+=s;var o=this.pScroller.clientHeight,l=this.pScrollbar.scrollTop,h={},a=this.NeedsScrollbar()||Infinity,c=e<r+10,u=n+r>a-10,f=this.pScroller.clientWidth,p=this.pScroller.scrollLeft,d=this.pLineNum.clientWidth,g=t<d+s+10;if(e<l)h.scrollTop=c?0:Math.max(0,e);else if(n>l+o)h.scrollTop=(u?a:n)-o;if(t<p+d||g){if(g)t=0;h.scrollLeft=Math.max(0,t-10-d)}else if(i>f+p-3){h.scrollLeft=i+10-f}return h},LocalCoords:function(t,e){var i,n=this.TextHeight(),s=n*(this.HeightAtLine(this.oDoc,t.line)-(e?this.displayOffset:0));if(t.ch==0)i=0;else i=this.MeasureLine(this.GetLine(t.line),t.ch).left;return{x:i,y:s,yBot:s+n}},CoordsChar:function(t,e){var i=this,n=this.TextHeight(),s=this.GetCharWidth(),r=this.displayOffset+Math.floor(e/n);if(r<0)return{line:0,ch:0};var o=this.LineAtHeight(this.oDoc,r);if(o>=this.oDoc.size)return{line:this.oDoc.size-1,ch:this.GetLine(this.oDoc.size-1).text.length};var l=this.GetLine(o),h=l.text,a=0;if(t<=0&&a==0)return{line:o,ch:0};var c=false;function u(t){var e=i.MeasureLine(l,t);return e.left}var f=0,p=0,d=h.length,g;var m=Math.min(d,Math.ceil((t+a*this.pScroller.clientWidth*.9)/s));while(true){var S=u(m);if(S<=t&&m<d){m=Math.min(d,Math.ceil(m*1.2))}else{g=S;d=m;break}}if(t>g)return{line:o,ch:d};m=Math.floor(d*.8);S=u(m);if(S<t){f=m;p=S}while(true){if(d-f<=1){var v=t-p<g-t;return{line:o,ch:v?f:d,after:v}}var x=Math.ceil((f+d)/2),C=u(x);if(C>t){d=x;g=C;if(c)g+=1e3}else{f=x;p=C}}},UpdateVerticalScroll:function(t){var e=this;var i=this.NeedsScrollbar();this.pScrollbar.style.display=i?"block":"none";if(i){this.pScrollbarInner.style.height=this.pSizeCont.style.minHeight=i+"px";this.pScrollbar.style.height=this.pScroller.clientHeight+"px";if(t!=null){this.pScrollbar.scrollTop=this.pScroller.scrollTop=t;if(BX.browser.IsSafari()||BX.browser.IsChrome()){setTimeout(function(){if(e.pScrollbar.scrollTop!=t)return;e.pScrollbar.scrollTop=t+(t?-1:1);e.pScrollbar.scrollTop=t},0)}}}else{this.pSizeCont.style.minHeight=""}this.pMover.style.top=this.displayOffset*this.TextHeight()+"px"},NeedsScrollbar:function(){var t=this.oDoc.size*this.TextHeight()+2*this.PaddingTop();return t*.99>this.pScroller.offsetHeight?t:false},PaddingTop:function(){return this.pLinesCont.offsetTop},PaddingLeft:function(){return this.pLinesCont.offsetLeft},PosFromMouse:function(t,e){var i=f(this.pScroller,true),n=t.clientX,s=t.clientY;if(!e&&(n-i.left>this.pScroller.clientWidth||s-i.top>this.pScroller.clientHeight))return null;var r=f(this.pLinesCont,true);return this.CoordsChar(n-r.left,s-r.top)},LineAtHeight:function(t,e){var i=0;t:do{for(var n=0,s=t.children.length;n<s;++n){var r=t.children[n],o=r.height;if(e<o){t=r;continue t}e-=o;i+=r.GetSize()}return i}while(!t.lines);for(var n=0;n<t.lines.length;++n){var l=t.lines[n],h=l.height;if(e<h)break;e-=h}return i+n},HeightAtLine:function(t,e){var i=0;t:do{for(var n=0,s=t.children.length;n<s;++n){var r=t.children[n],o=r.GetSize();if(e<o){t=r;continue t}e-=o;i+=r.height}return i}while(!t.lines);for(var n=0;n<e;++n)i+=t.lines[n].height;return i},GetUnchanged:function(t,e){var i,n,s,r,o,l=e.length||0,h;for(o=0;o<l;++o){i=e[o];n=[];s=i.diff||0;for(h=0;h<t.length;++h){r=t[h];if(i.to<=r.from&&i.diff){n.push({from:r.from+s,to:r.to+s,domStart:r.domStart})}else if(i.to<=r.from||i.from>=r.to){n.push(r)}else{if(i.from>r.from)n.push({from:r.from,to:i.from,domStart:r.domStart});if(i.to<r.to)n.push({from:i.to+s,to:r.to+s,domStart:r.domStart+(i.to-r.from)})}}t=n}return t},PatchDisplay:function(t,e,i){function n(t){var e=t.nextSibling;t.parentNode.removeChild(t);return e}if(!i.length){BX.cleanNode(this.pLineDiv)}else{var s=0,r,o,l,h,a=this.pLineDiv.firstChild,c;for(r=0;r<i.length;++r){o=i[r];while(o.domStart>s){a=n(a);s++}for(l=0,h=o.to-o.from;l<h;++l){a=a.nextSibling;s++}}while(a)a=n(a)}var u=this,f=i.shift(),l=t;a=this.pLineDiv.firstChild;this.oDoc.Iteration(t,e,function(t){var e;if(f&&f.to==l)f=i.shift();if(!f||f.from>l){if(t.hidden){e=BX.create("PRE")}else{e=t.getElement(BX.proxy(u.MakeTab,u));if(t.className)e.className=t.className;if(t.bgClassName)e=BX.create("DIV",{children:[BX.create("PRE",{html:"\xa0",props:{className:t.bgClassName},style:{position:"absolute",left:0,right:0,top:0,bottom:0,zIndex:-2}}),e],style:{position:"relative"}})}u.pLineDiv.insertBefore(e,a)}else{a=a.nextSibling}++l})},UpdateLineNum:function(){var t=this.pMover.offsetHeight,e=this.pScroller.clientHeight,i=document.createDocumentFragment(),n=this.showingFrom,s;this.pLineNum.style.height=(t-e<2?e:t)+"px";this.oDoc.Iteration(this.showingFrom,Math.max(this.showingTo,this.showingFrom+1),function(t){if(t.hidden){i.appendChild(BX.create("PRE"))}else{var e=i.appendChild(BX.create("PRE",{html:n+1}));for(var r=1;r<t.height;++r){e.appendChild(BX.create("BR"));e.appendChild(document.createTextNode("\xa0"))}s=n}++n});this.pLineNum.style.display="none";BX.cleanNode(this.pLineNumText);this.pLineNumText.appendChild(i);if(s!=null){var r="",o=this.pLineNumText.childNodes[s-this.showingFrom],l=String(this.oDoc.size).length,h=o.firstChild,a="";if(h)r=h.textContent||h.innerText||h.nodeValue||"";while(r.length+a.length<l)a+="\xa0";if(a)o.insertBefore(document.createTextNode(a),o.firstChild)}this.pLineNum.style.display="";var c=parseInt(this.pLineNum.offsetWidth);if(c>=53)c=53;var u=Math.abs((parseInt(this.pLinesCont.style.marginLeft)||0)-c)>2;this.pLinesCont.style.marginLeft=c+"px";this.lineNumDirty=false;return u},UpdateSelection:function(){var t=this.PosEq(this.oSel.from,this.oSel.to),e=this.LocalCoords(this.oSel.from,true),i=t?e:this.LocalCoords(this.oSel.to,true),n=this.oSel.inverted?e:i,s=this.TextHeight(),r=f(this.pInnerContHL),o=f(this.pLineDiv);this.pInputCont.style.top=Math.max(0,Math.min(this.pScroller.offsetHeight,n.y+o.top-r.top))+"px";this.pInputCont.style.left=Math.max(0,Math.min(this.pScroller.offsetWidth,n.x+o.left-r.left))+"px";if(t){this.pCursor.style.top=n.y+"px";this.pCursor.style.left=n.x+"px";this.pCursor.style.display="";this.pSelectionDiv.style.display="none"}else{var l=e.y==i.y,h=document.createDocumentFragment(),a=this.pLinesCont.clientWidth||this.pLinesCont.offsetWidth,c=this.pLinesCont.clientHeight||this.pLinesCont.offsetHeight;function u(t,e,i,n){var s=h.appendChild(BX.create("DIV",{props:{className:"bxce-selected"},style:{position:"absolute",left:t+"px",top:e+"px",height:n+"px"}}));s.style.width=(i?a-i-t:a)+"px"}if(this.oSel.from.ch&&e.y>=0){var p=l?a-i.x:0;u(e.x,e.y,p,s)}var d=Math.max(0,e.y+(this.oSel.from.ch?s:0));var g=Math.min(i.y,c)-d;if(g>.2*s)u(0,d,0,g);if((!l||!this.oSel.from.ch)&&i.y<c-.5*s)u(0,i.y,a-i.x,s);BX.cleanNode(this.pSelectionDiv);this.pSelectionDiv.appendChild(h);this.pCursor.style.display="none";this.pSelectionDiv.style.display=""}},OnScrollBar:function(t){if(this.pScrollbar.scrollTop!=this._lastScrollTop){this._lastScrollTop=this.pScroller.scrollTop=this.pScrollbar.scrollTop;this.UpdateDisplay([])}},OnScrollMain:function(t){if(this.pLineNum.style.left!=this.pScroller.scrollLeft+"px")this.pLineNum.style.left=this.pScroller.scrollLeft+"px";if(this.pScroller.scrollTop!=this._lastScrollTop){this._lastScrollTop=this.pScroller.scrollTop;if(this.pScrollbar.scrollTop!=this._lastScrollTop)this.pScrollbar.scrollTop=this._lastScrollTop;this.UpdateDisplay([])}},OnMouseDown:function(t){if(!t)t=window.event;if(!this.highlightMode)return;if(t.button&&t.button!==0)return;this.SetShift(t.shiftKey);var e,i=t.target||t.srcElement;for(e=i;e!=this.pInnerContHL;e=e.parentNode)if(e.parentNode==this.pSizeCont&&e!=this.pMover)return;for(e=i;e!=this.pInnerContHL;e=e.parentNode)if(e.parentNode==this.pLineNumText)return BX.PreventDefault(t);var n=this.PosFromMouse(t);if(a(t)==2){if(n)this.SetCursor(n.line,n.ch,true);setTimeout(BX.proxy(this.FocusInput,this),20);return BX.PreventDefault(t)}if(!n){if(i==this.pScroller)BX.PreventDefault(t);return}if(!this.focused)this.OnFocus();var s=+new Date;this._type="single";if(this.lastDoubleClick&&this.lastDoubleClick.time>s-400&&this.PosEq(this.lastDoubleClick.pos,n)){this._type="triple";BX.PreventDefault(t);setTimeout(BX.proxy(this.FocusInput,this),20);this.SelectLine(n.line)}else if(this.lastClick&&this.lastClick.time>s-400&&this.PosEq(this.lastClick.pos,n)){this._type="double";this.LastDoubleClick={time:s,pos:n};BX.PreventDefault(t);var r=this.FindWordAt(n);this.SetSelectionUser(r.from,r.to)}else{this.lastClick={time:s,pos:n}}this._selectingTimeout=null;this._last=n;this._start=n;BX.PreventDefault(t);if(this._type=="single")this.SetCursor(n.line,n.ch,true);this._startstart=this.oSel.from;this._startend=this.oSel.to;BX.bind(document,"mousemove",BX.proxy(this.OnMouseMove,this));BX.bind(document,"mouseup",BX.proxy(this._OnDone,this))},_DoSelect:function(t){if(this._type=="single"){this.SetSelectionUser(this._start,t)}else if(this._type=="double"){var e=this.FindWordAt(t);if(this.PosLess(t,this._startstart))this.SetSelectionUser(e.from,this._startend);else this.SetSelectionUser(this._startstart,e.to)}else if(this._type=="triple"){if(this.PosLess(t,this._startstart))this.SetSelectionUser(this._startend,this.ClipPos({line:t.line,ch:0}));else this.SetSelectionUser(this._startstart,this.ClipPos({line:t.line+1,ch:0}))}},OnMouseMove:function(t){this.OnBeforeAction();if(this._selectingTimeout)this._selectingTimeout=clearTimeout(this._selectingTimeout);BX.PreventDefault(t);if(!BX.browser.IsIE()&&!a(t))this._OnDone(t);else this._OnExtend(t);this.OnAfterAction()},_OnDone:function(t){if(this._selectingTimeout)this._selectingTimeout=clearTimeout(this._selectingTimeout);var e=this.PosFromMouse(t);if(e)this._DoSelect(e);BX.PreventDefault(t);this.FocusInput();this.updateInput=true;this.ResetInput(this.userSelChange);BX.unbind(document,"mousemove",BX.proxy(this.OnMouseMove,this));BX.unbind(document,"mouseup",BX.proxy(this._OnDone,this))},_OnExtend:function(t){var e=this,i=this.PosFromMouse(t,true);if(i&&!this.PosEq(i,this._last)){if(!this.focused)this.OnFocus();this._last=i;this._DoSelect(i);this.updateInput=false;var n=this.VisibleLines();if(i.line>=n.to||i.line<n.from)this._selectingTimeout=setTimeout(this.Action(function(){e._OnExtend(t)},this),150)}},OnDoubleClick:function(t){return BX.PreventDefault(t)},DoHandleBinding:function(t,e){if(typeof t=="string"){t=this.GetCommand(t);if(!t)return false}var i=this.shiftSelecting;try{if(e)this.suppressEdits=null;t()}catch(t){throw t;return false}finally{this.shiftSelecting=i;this.suppressEdits=false}return true},HandleKeyBinding:function(t){var e=this,i=this.keyNames[t.keyCode],n=false;if(i==null||t.altGraphKey)return false;if(t.altKey)i="Alt-"+i;if(t.ctrlKey)i="Ctrl-"+i;if(t.metaKey)i="Cmd-"+i;var s=false;function r(){s=true}if(t.shiftKey){n=this.LookupKey("Shift-"+i,function(t){return e.DoHandleBinding(t,true)},r)||this.LookupKey(i,function(t){if(typeof t=="string"&&/^go[A-Z]/.test(t))return e.DoHandleBinding(t)},r)}else{n=this.LookupKey(i,BX.proxy(this.DoHandleBinding,this),r)}if(s)n=false;if(n){BX.PreventDefault(t);this.RestartBlink();if(BX.browser.IsIE()){t.oldKeyCode=t.keyCode;t.keyCode=0}}return n},HandleCharBinding:function(t,e){var i=this;var n=this.LookupKey("'"+e+"'",function(t){return i.DoHandleBinding(t,true)});if(n){BX.PreventDefault(t);i.RestartBlink()}return n},OnKeyDown:function(t){if(!this.focused)this.OnFocus();if(BX.browser.IsIE()&&t.keyCode==27)t.returnValue=false;if(this.pollingFast&&this.ReadInput())this.pollingFast=false;var e=t.keyCode;this.SetShift(e==16||t.shiftKey);var i=this.HandleKeyBinding(t);if(BX.browser.IsOpera()){this._lastStoppedKey=i?e:null;if(!i&&e==88&&t.ctrlKey)this.ReplaceSelection("")}},OnKeyPress:function(t){if(this.pollingFast)this.ReadInput();var e=t.keyCode,i=t.charCode;if(BX.browser.IsOpera()&&e==this._lastStoppedKey){this._lastStoppedKey=null;return BX.PreventDefault(t)}if(BX.browser.IsOpera()&&(!t.which||t.which<10)&&this.HandleKeyBinding(t))return;var n=String.fromCharCode(i==null?e:i);if(this.oSyntax.magicSym&&this.oSyntax.magicSym.indexOf(n)>-1)setTimeout(this.Action(function(){this.IndentLine(this.oSel.to.line,"smart")},this),75);if(this.HandleCharBinding(t,n))return;this.FastPoll()},OnKeyUp:function(t){if(t.keyCode==16)this.shiftSelecting=null},OnFocus:function(){if(!this.focused){this.focused=true;BX.addClass(this.pScroller,"bxce-focused");this.ResetInput(true)}this.SlowPoll();this.RestartBlink()},OnBlur:function(){this.Save();var t=this;if(this.focused){this.focused=false;if(this.bracketHighlighted){this.Action(function(){if(this.bracketHighlighted){this.bracketHighlighted();this.bracketHighlighted=null}},this)}BX.removeClass(this.pScroller,"bxce-focused")}if(this._blinkerInterval)this._blinkerInterval=clearInterval(this._blinkerInterval);setTimeout(function(){if(!t.focused)t.shiftSelecting=null},150)},ReplaceRange:function(t,e,i){var n=this;e=this.ClipPos(e);i=i?this.ClipPos(i):e;t=this.ExplodeLines(t);function s(s){if(n.PosLess(s,e))return s;if(!n.PosLess(i,s))return r;var o=s.line+t.length-(i.line-e.line)-1;var l=s.ch;if(s.line==i.line)l+=t[t.length-1].length-(i.ch-(i.line==e.line?e.ch:0));return{line:o,ch:l}}var r;this.ReplaceRange1(t,e,i,function(t){r=t;return{from:s(n.oSel.from),to:s(n.oSel.to)}});return r},ReplaceSelection:function(t,e){var i=this;this.ReplaceRange1(this.ExplodeLines(t),this.oSel.from,this.oSel.to,function(t){if(e=="end")return{from:t,to:t};else if(e=="start")return{from:i.oSel.from,to:i.oSel.from};else return{from:i.oSel.from,to:t}})},ReplaceRange1:function(t,e,i,n){var s=t.length==1?t[0].length+e.ch:t[t.length-1].length,r=n({line:e.line+t.length-1,ch:s});this.UpdateLines(e,i,t,r.from,r.to)},GetRange:function(t,e,i){var n=t.line,s=e.line;if(n==s)return this.GetLine(n).text.slice(t.ch,e.ch);var r=[this.GetLine(n).text.slice(t.ch)];this.oDoc.Iteration(n+1,s,function(t){r.push(t.text)});r.push(this.GetLine(s).text.slice(0,e.ch));return r.join(i||"\n")},GetSelection:function(t){return this.GetRange(this.oSel.from,this.oSel.to,t)},SlowPoll:function(){if(!this.pollingFast)this.pollDelayed.set(this.pollInterval,BX.proxy(this.OnSlowPoolRun,this))},OnSlowPoolRun:function(){if(!this.highlightMode)return BX.DoNothing;this.OnBeforeAction();this.ReadInput();if(this.focused)this.SlowPoll();this.OnAfterAction()},FastPoll:function(){var t=this,e=false;this.pollingFast=true;function i(){t.OnBeforeAction();var n=t.ReadInput();if(!n&&!e){e=true;t.pollDelayed.set(60,i)}else{t.pollingFast=false;t.SlowPoll()}t.OnAfterAction()}this.pollDelayed.set(20,i)},ChangeLine:function(t,e){var i=t,n=t;if(typeof t=="number")n=this.GetLine(this.ClipLine(t));else i=this.LineNo(t);if(i==null)return null;if(e(n,i))this.arChanges.push({from:i,to:i+1});else return null;return n},SetLineHidden:function(t,e){var i=this;return this.ChangeLine(t,function(t,n){if(t.hidden!=e){t.hidden=e;if(e&&t.text.length==this.maxLine.text.length){this.updateMaxLine=true}else if(!e&&t.text.length>this.maxLine.text.length){this.maxLine=t;this.updateMaxLine=false}i.UpdateLineHeight(t,e?0:1);var s=this.oSel.from.line,r=this.oSel.to.line;if(e&&(s==n||r==n)){var o=s==n?i.SkipHidden({line:s,ch:0},s,0):this.oSel.from;var l=r==n?i.SkipHidden({line:r,ch:0},r,0):this.oSel.to;if(!l)return;i.SetSelection(o,l)}return i.lineNumDirty=true}})},UpdateLineHeight:function(t,e){this.lineNumDirty=true;var i=e-t.height;for(var n=t;n;n=n.parent)n.height+=i},SkipHidden:function(t,e,i){var n=this;function s(e){var s=t.line+e,r=e==1?n.oDoc.size:-1;while(s!=r){var l=getLine(s);if(!l.hidden){var h=t.ch;if(o||h>i||h>l.text.length)h=l.text.length;return{line:s,ch:h}}s+=e}}var r=this.GetLine(t.line),o=t.ch==r.text.length&&t.ch!=i;if(!r.hidden)return t;if(t.line>=e)return s(1)||s(-1);else return s(-1)||s(1)},SelectLine:function(t){this.SetSelectionUser({line:t,ch:0},this.ClipPos({line:t+1,ch:0}))},IndentSelected:function(t){if(this.PosEq(this.oSel.from,this.oSel.to))return this.IndentLine(this.oSel.from.line,t);var e=this.oSel.to.line-(this.oSel.to.ch?0:1);for(var i=this.oSel.from.line;i<=e;++i)this.IndentLine(i,t)},IndentLine:function(t,e){if(!e)e="add";if(e=="smart"){if(!this.oSyntax.Indent)e="prev";else var i=this.GetStateBefore(t)}var n=this.GetLine(t),s=n.indentation(this.tabSize),r=n.text.match(/^\s*/)[0],o;if(e=="smart"){o=this.oSyntax.Indent(i,n.text.slice(r.length),n.text)}if(e=="prev")o=t?this.GetLine(t-1).indentation(this.tabSize):0;else if(e=="add")o=s+this.indentUnit;else if(e=="subtract")o=s-this.indentUnit;o=Math.max(0,o);var l,h="",a=0;for(l=Math.floor(o/this.tabSize);l;--l){a+=this.tabSize;h+="\t"}while(a<o){++a;h+=" "}if(h!=r)this.ReplaceRange(h,{line:t,ch:0},{line:t,ch:r.length})},FindPosH:function(t,e){var i=this,n=this.oSel.inverted?this.oSel.from:this.oSel.to,s=n.line,r=n.ch,o=this.GetLine(s);function l(){var e,n,r;for(e=s+t,r=t<0?-1:i.oDoc.size;e!=r;e+=t){n=i.GetLine(e);if(!n.hidden){s=e;o=n;return true}}return false}function h(e){if(r==(t<0?0:o.text.length)){if(!e&&l())r=t<0?o.text.length:0;else return false}else{r+=t}return true}if(e=="char"){h()}else if(e=="column"){h(true)}else if(e=="word"){var a=false;for(;;){if(t<0)if(!h())break;if(d(o.text.charAt(r))){a=true}else if(a){if(t<0){t=1;h()}break}if(t>0&&!h())break}}return{line:s,ch:r}},MoveH:function(t,e){var i=t<0?this.oSel.from:this.oSel.to;if(this.shiftSelecting||this.PosEq(this.oSel.from,this.oSel.to))i=this.FindPosH(t,e);this.SetCursor(i.line,i.ch,true)},DeleteH:function(t,e){if(!this.PosEq(this.oSel.from,this.oSel.to))this.ReplaceRange("",this.oSel.from,this.oSel.to);else if(t<0)this.ReplaceRange("",this.FindPosH(t,e),this.oSel.to);else this.ReplaceRange("",this.oSel.from,this.FindPosH(t,e));this.userSelChange=true},MoveV:function(t,e){var i,n,s,r=this.LocalCoords(this.oSel.inverted?this.oSel.from:this.oSel.to,true);if(this.goalColumn!=null)r.x=this.goalColumn;if(e=="page"){i=Math.min(this.pScroller.clientHeight,window.innerHeight||document.documentElement.clientHeight);n=this.CoordsChar(r.x,r.y+i*t)}else if(e=="line"){s=this.TextHeight();n=this.CoordsChar(r.x,r.y+.5*s+t*s)}if(e=="page")this.pScrollbar.scrollTop+=this.LocalCoords(n,true).y-r.y;this.SetCursor(n.line,n.ch,true);this.goalColumn=r.x},FindWordAt:function(t){var e=this.GetLine(t.line).text,i=t.ch,n=t.ch;if(e){if(t.after===false||n==e.length)--i;else++n;var s=e.charAt(i),r=d(s)?d:/\s/.test(s)?function(t){return/\s/.test(t)}:function(t){return!/\s/.test(t)&&!d(t)};while(i>0&&r(e.charAt(i-1)))--i;while(n<e.length&&r(e.charAt(n)))++n}return{from:{line:t.line,ch:i},to:{line:t.line,ch:n}}},InitKeyEngine:function(){this.Map={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goHome",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharRight",Backspace:"delCharLeft",Tab:"tab","Shift-Tab":"indentLess",Enter:"newlineAndIndent",Insert:"toggleOverwrite"};if(BX.browser.IsMac()){this.Map["Cmd-A"]="selectAll";this.Map["Cmd-D"]="deleteLine";this.Map["Cmd-Z"]="undo";this.Map["Cmd-Up"]="goDocStart";this.Map["Cmd-End"]="goDocEnd";this.Map["Cmd-Down"]="goDocEnd";this.Map["Alt-Left"]="goWordLeft";this.Map["Alt-Right"]="goWordRight";this.Map["Cmd-Left"]="goLineStart";this.Map["Cmd-Right"]="goLineEnd";this.Map["Alt-Backspace"]="delWordLeft";this.Map["Ctrl-Alt-Backspace"]="delWordRight";this.Map["Alt-Delete"]="delWordRight"}else{this.Map["Ctrl-A"]="selectAll";this.Map["Ctrl-D"]="deleteLine";this.Map["Ctrl-Z"]="undo";this.Map["Ctrl-Home"]="goDocStart";this.Map["Alt-Up"]="goDocStart";this.Map["Ctrl-End"]="goDocEnd";this.Map["Ctrl-Down"]="goDocEnd";this.Map["Ctrl-Left"]="goWordLeft";this.Map["Ctrl-Right"]="goWordRight";this.Map["Alt-Left"]="goLineStart";this.Map["Alt-Right"]="goLineEnd";this.Map["Ctrl-Backspace"]="delWordLeft";this.Map["Ctrl-Delete"]="delWordRight"}this.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};var t;for(t=0;t<10;t++)this.keyNames[t+48]=String(t);for(t=65;t<=90;t++)this.keyNames[t]=String.fromCharCode(t);for(t=1;t<=12;t++)this.keyNames[t+111]=this.keyNames[t+63235]="F"+t},LookupKey:function(t,e,i){var n=this.Map[t];if(n===false){if(i&&typeof i=="function")i();return true}return n!=null&&e(n)},GetCommand:function(t){return{selectAll:BX.proxy(function(){this.DoSelection({line:0,ch:0},{line:this.oDoc.size-1})},this),killLine:BX.proxy(function(){var t=this.GetCursor(true),e=this.GetCursor(false),i=!this.PosEq(t,e);if(!i&&this.GetLineText(t.line).length==t.ch)this.ReplaceRange("",t,{line:t.line+1,ch:0});else this.ReplaceRange("",t,i?e:{line:t.line})},this),deleteLine:BX.proxy(function(){var t=this.GetCursor().line;this.ReplaceRange("",{line:t,ch:0},{line:t})},this),goCharLeft:BX.proxy(function(){this.MoveH(-1,"char")},this),goCharRight:BX.proxy(function(){this.MoveH(1,"char")},this),goColumnLeft:BX.proxy(function(){this.MoveH(-1,"column")},this),goColumnRight:BX.proxy(function(){this.MoveH(-1,"column")},this),goDocStart:BX.proxy(function(){this.SetCursor(0,0,true)},this),goDocEnd:BX.proxy(function(){this.DoSelection({line:this.oDoc.size-1},null,true)},this),goLineStart:BX.proxy(function(){this.SetCursor(this.GetCursor().line,0,true)},this),goHome:BX.proxy(function(){var t=this.GetCursor(),e=this.GetLineText(t.line),i=Math.max(0,e.search(/\S/));this.SetCursor(t.line,t.ch<=i&&t.ch?0:i,true)},this),goLineEnd:BX.proxy(function(){this.DoSelection({line:this.GetCursor().line},null,true)},this),goLineUp:BX.proxy(function(){this.MoveV(-1,"line")},this),goLineDown:BX.proxy(function(){this.MoveV(1,"line")},this),goPageUp:BX.proxy(function(){this.MoveV(-1,"page")},this),goPageDown:BX.proxy(function(){this.MoveV(1,"page")},this),goWordLeft:BX.proxy(function(){this.MoveH(-1,"word")},this),goWordRight:BX.proxy(function(){this.MoveH(1,"word")},this),delCharLeft:BX.proxy(function(){this.DeleteH(-1,"char")},this),delCharRight:BX.proxy(function(){this.DeleteH(1,"char")},this),delWordLeft:BX.proxy(function(){this.DeleteH(-1,"word")},this),delWordRight:BX.proxy(function(){this.DeleteH(1,"word")},this),indentLess:BX.proxy(function(){this.IndentSelection("subtract")},this),tab:BX.proxy(function(){if(this.PosEq(this.oSel.from,this.oSel.to)){this.ReplaceSelection("\t","end")}else{this.IndentSelection("add")}},this),undo:BX.proxy(this.Undo,this),enter:BX.proxy(function(){this.ReplaceSelection("\n","end");this.IndentLine(this.GetCursor().line)},this)}[t]},IndentSelection:function(t){this.OnBeforeAction();this.IndentSelected(t);this.OnAfterAction()},DoSelection:function(t,e,i){this.OnBeforeAction();var n=this.ClipPos(t),s=this.ClipPos(e||t);if(i)this.SetSelectionUser(n,s);else this.SetSelection(n,s);this.OnAfterAction()},GetLineText:function(t){if(t>=0&&t<this.oDoc.size)return this.GetLine(t).text;return""},CheckLinesHeight:function(t,e,i){var n=t.split("\n"),s,r,o,l=false,h;i=n.length-1;e=0;for(s=e;s<=i;s++){if(r=this.pLineNumTA.childNodes[s]){o=this.GetLineHeight(n[s]);h=parseInt(r.style.height);if(o>this.lineHeight||r.style.height!=""){r.style.height=n[s]?o+"px":"";if(h!=o)l=true}}}return l},BuildLineNum:function(t){t=parseInt(t);if(t!==this.lineNums){if(t<1)t=1;if(this.lineNums<t){for(var e=this.lineNums+1;e<=t;e++)this.pLineNumTA.appendChild(BX.create("DIV",{html:e}));this.lineNums=t}}},TextOnKeydown:function(t){if(!t)t=window.event;var e=t.which||t.keyCode;if(e==9){this.OnTab(t,this.ShiftPressed(t));return BX.PreventDefault(t)}},TextOnKeyup:function(t,e){if(!t)t=window.event;if(!e)e=t.which||t.keyCode;if(!{17:true,18:true,9:true,27:true}[e])this.CheckLineSelection()},TextOnMousedown:function(t){this.MoveLineSelection(true)},ShiftPressed:function(t){if(window.event)return!!window.event.shiftKey;return!!(t.shiftKey||t.modifiers>3)},OnTab:function(t,e){if(this.bDisableTab)return;if(BX.browser.IsIE())this.bDisableTab=true;var i,n,s,r,o="\t",h=this.GetTASelection(),a=h.start,c=h.end,u=this.GetTAValue().replace(/\r/g,""),f=u.substring(a,c),p=a,d=c;if(!e){if(f==""){u=u.substr(0,a)+o+u.substr(c);p=a+1;d=p}else{a=u.substr(0,a).lastIndexOf("\n")+1;if(a<=0)a=0;n=u.substr(c);s=u.substr(0,a);r=u.substring(a,c).split("\n");f=o+r.join("\n"+o);u=s+f+n;p=a;d=u.indexOf("\n",s.length+f.length);if(d==-1)d=u.length}}else{if(f==""){if(a<=0)a=1;if(u.substring(a-1,a)==o){u=u.substr(0,a-1)+u.substr(c);p=d=a-1}}else{a=u.substr(0,a).lastIndexOf("\n")+1;n=u.substr(c);s=u.substr(0,a);r=u.substring(a,c).split("\n");f="";for(i=0;i<r.length;i++){for(j=0,l=this.tabSymTA.length;j<l;j++){if(r[i].charAt(0)==o){r[i]=r[i].substr(1);j=l}}f+=r[i];if(i<r.length-1)f+="\n"}u=s+f+n;p=a;d=u.indexOf("\n",s.length+f.length);if(d==-1)d=u.length}}this.SetTAValue(u);if(BX.browser.IsIE()){var g=this;this.SetIETASelection(p,d);setTimeout(function(){g.bDisableTab=false},80)}else{this.pTA.selectionStart=p;this.pTA.selectionEnd=d}this.CheckLineSelection(true)},CheckLineSelection:function(t){if(this.highlightMode)return;var e=this.GetSelectionInfo();if(t!==false||e.source!=this.curSel.source)this.ManageSize(false);this.curSel=e},ManageSize:function(t){if(this.highlightMode)return false;var e,i;i=parseInt(this.pTA.scrollHeight,10);this.curSel=this.GetSelectionInfo();if(!isNaN(i)&&i>=0){this.pContTA.style.height=i+2+"px";this.pTA.style.height=i+2+"px"}e=this.pTA.scrollWidth;if(BX.browser.IsChrome()){e+=18}if(parseInt(this.pTA.style.width)<e){this.pTA.style.width=e+"px";this.pContTA.style.width=e+"px"}if(t!==false)this.CheckLineSelection(true);if(this.curSel.nbLine>=0){this.BuildLineNum(this.curSel.nbLine);var n=this.GetLinePos(this.curSel.nbLine);if(n.top+n.height<i&&this.curSel.nbLine<this.lineNums){var s=parseInt(n.top+n.height);if(!isNaN(s)&&s>=0){this.pContTA.style.height=s+2+"px";this.pTA.style.height=s+2+"px"}}}this.pTA.scrollTop="0px";this.pTA.scrollLeft="0px"},GetSelectionInfo:function(){if(!this.curSel)this.curSel={};var t=this.GetTASelection(),e=t.start,i=t.end,n;var s={selectionStart:e,selectionEnd:i,source:this.GetTAValue().replace(/\r/g,""),linePos:1,lineNb:1,carretPos:0,curLine:"",cursorIndex:0,direction:this.curSel.direction},r=s.source.split("\n"),o=r.length,l=s.source.length-(o-1);if(l<0)l=0;s.nbLine=o;s.nbChar=l;if(e>0){n=s.source.substr(0,e);s.carretPos=e-n.lastIndexOf("\n");s.linePos=n.split("\n").length}else{s.carretPos=1}if(s.linePos<1)s.linePos=1;if(i>e)s.lineNb=s.source.substring(e,i).split("\n").length;s.cursorIndex=e;s.curLine=r[s.linePos-1];if(s.selectionStart==this.curSel.selectionStart){if(s.selectionEnd>this.curSel.selectionEnd)s.direction="down";else s.direction=this.curSel.direction}else if(s.selectionStart==this.curSel.selectionEnd&&s.selectionEnd>this.curSel.selectionEnd){s.direction="down"}else{s.direction="up"}this.SetStatusBarInfo(s);return s},GetTASelection:function(){var t=0,e=0;try{if(BX.browser.IsIE9()||this.pTA.selectionStart!=undefined){t=this.pTA.selectionStart;e=this.pTA.selectionEnd}else if(BX.browser.IsIE()){var i="\x01";var n=document.selection.createRange();var s=n.text.replace(/\r/g,"");var r=n.duplicate();if(s!="")n.collapse();r.moveToElementText(this.pTA);n.text=i;e=t=r.text.replace(/\r/g,"").indexOf(i);n.moveStart("character",-1);n.text="";if(s!="")e+=s.length}else{t=this.pTA.selectionStart;e=this.pTA.selectionEnd}}catch(i){t=0;e=0}return{start:t,end:e}},GetLinePos:function(t){var e=this.pLineNumTA.childNodes[t-1],i=e?e.offsetTop:this.lineHeight*(t-1),n=e?e.offsetHeight:this.lineHeight;return{top:parseInt(i)||0,height:parseInt(n)||0}},Undo:function(){this.UndoRedo(this.oHistory.done,this.oHistory.undone)},UndoRedo:function(t,e){if(!t.length)return;var i,n,s,r,o,l=t.pop(),h=[];for(i=l.length-1;i>=0;i-=1){n=l[i];s=[];r=n.start+n.added;o={line:n.start+n.old.length-1,ch:this.GetUndoChar(s[s.length-1],n.old[n.old.length-1])};this.UpdateLinesNoUndo({line:n.start,ch:0},{line:r-1,ch:this.GetLine(r-1).text.length},n.old,o,o)}this.updateInput=true;e.push(h)},GetUndoChar:function(t,e){if(!e)return 0;if(!t)return e.length;for(var i=t.length,n=e.length;i>=0&&n>=0;--i,--n)if(t.charAt(i)!=e.charAt(n))break;return n+1}};function t(t,e){this.pos=this.start=0;this.string=t;this.tabSize=e||8}t.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(t){var e=this.string.charAt(this.pos),i=typeof t=="string"?e==t:e&&(t.test?t.test(e):t(e));if(i){++this.pos;return e}},eatWhile:function(t){var e=this.pos;while(this.eat(t)){}return this.pos>e},eatSpace:function(){var t=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>t},skipToEnd:function(){this.pos=this.string.length},skipTo:function(t){var e=this.string.indexOf(t,this.pos);if(e>-1){this.pos=e;return true}},backUp:function(t){this.pos-=t},column:function(){return u(this.string,this.start,this.tabSize)},indentation:function(){return u(this.string,null,this.tabSize)},match:function(t,e,i){var n;if(typeof t=="string"){var s=function(t){return i?t.toLowerCase():t};if(s(this.string).indexOf(s(t),this.pos)==this.pos){if(e!==false)this.pos+=t.length;return true}}else if(t!==null){n=this.string.slice(this.pos).match(t);if(n&&e!==false)this.pos+=n[0].length}return n},current:function(){return this.string.slice(this.start,this.pos)}};function e(t,e){this.styles=e||[t,null];this.text=t;this.height=1}e.inheritMarks=function(t,i){var n=new e(t),s=i&&i.marked;if(s){for(var r=0;r<s.length;++r){if(s[r].to==null&&s[r].style){var o=n.marked||(n.marked=[]),l=s[r],h=l.dup();o.push(h);h.attach(n)}}}return n};e.prototype={Replace:function(t,e,i){var s=[],r=this.marked,o=e==null?this.text.length:e;n(0,t,this.styles,s);if(i)s.push(i,null);n(o,this.text.length,this.styles,s);this.styles=s;this.text=this.text.slice(0,t)+i+this.text.slice(o);this.statusAfter=null;if(r){var l=i.length-(o-t);for(var h=0;h<r.length;++h){var a=r[h];a.clipTo(t==null,t||0,e==null,o,l);if(a.isDead()){a.detach(this);r.splice(h--,1)}}}},split:function(t,i){var s=[i,null],r=this.marked;n(t,this.text.length,this.styles,s);var o=new e(i+this.text.slice(t),s);if(r){for(var l=0;l<r.length;++l){var h=r[l];var a=h.split(t,i.length);if(a){if(!o.marked)o.marked=[];o.marked.push(a);a.attach(o);if(a==h)r.splice(l--,1)}}}return o},append:function(t){var e=this.text.length,i=t.marked,s=this.marked;this.text+=t.text;n(0,t.text.length,t.styles,this.styles);if(s){for(var r=0;r<s.length;++r)if(s[r].to==null)s[r].to=e}if(i&&i.length){if(!s)this.marked=s=[];t:for(var r=0;r<i.length;++r){var o=i[r];if(!o.from){for(var l=0;l<s.length;++l){var h=s[l];if(h.to==e&&h.sameSet(o)){h.to=o.to==null?null:o.to+e;if(h.isDead()){h.detach(this);i.splice(r--,1)}continue t}}}s.push(o);o.attach(this);o.from+=e;if(o.to!=null)o.to+=e}}},fixMarkEnds:function(t){var e=this.marked,i=t.marked;if(!e)return;t:for(var n=0;n<e.length;++n){var s=e[n],r=s.to==null;if(r&&i){for(var o=0;o<i.length;++o){var l=i[o];if(!l.sameSet(s)||l.from!=null)continue;if(s.from==this.text.length&&l.to==0){i.splice(o,1);e.splice(n--,1);continue t}else{r=false;break}}}if(r)s.to=this.text.length}},fixMarkStarts:function(){var t=this.marked;if(!t)return;for(var e=0;e<t.length;++e)if(t[e].from==null)t[e].from=0},addMark:function(t){t.attach(this);if(this.marked==null)this.marked=[];this.marked.push(t);this.marked.sort(function(t,e){return(t.from||0)-(e.from||0)})},highlight:function(e,i,n){var s=new t(this.text,n),r=this.styles,o=0;var l=false,h=r[0],a;if(this.text==""&&e.blankLine)e.blankLine(i);while(!s.eol()){var c=e.HandleChar(s,i);var u=this.text.slice(s.start,s.pos);s.start=s.pos;if(o&&r[o-1]==c){r[o-2]+=u}else if(u){if(!l&&(r[o+1]!=c||o&&r[o-2]!=a))l=true;r[o++]=u;r[o++]=c;a=h;h=r[o]}if(s.pos>5e3){r[o++]=this.text.slice(s.pos);r[o++]=null;break}}if(r.length!=o){r.length=o;l=true}if(o&&r[o-2]!=a)l=true;return l||(r.length<5&&this.text.length<10?null:false)},getTokenAt:function(e,i,n,s){var r,o=this.text,l=new t(o,n);while(l.pos<s&&!l.eol()){l.start=l.pos;r=e.HandleChar(l,i)}return{start:l.start,end:l.pos,string:l.current(),className:r||null,status:i}},indentation:function(t){return u(this.text,null,t)},getElement:function(t,e,i){var n=this;var s=true,r=0,o=/[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g;var l=BX.create("PRE");function h(e,i,n){if(!i)return;if(s&&BX.browser.IsIE()&&i.charAt(0)==" ")i="\xa0"+i.slice(1);s=false;if(!o.test(i)){r+=i.length;var l=document.createTextNode(i)}else{var l=document.createDocumentFragment(),h=0;while(true){o.lastIndex=h;var a=o.exec(i);var c=a?a.index-h:i.length-h;if(c){l.appendChild(document.createTextNode(i.slice(h,h+c)));r+=c}if(!a)break;h+=c+1;if(a[0]=="\t"){var u=t(r);l.appendChild(u.element.cloneNode(true));r+=u.width}else{l.appendChild(BX.create("TT",{props:{className:"bxce-invalidchar",title:"\\u"+a[0].charCodeAt(0).toString(16)},html:"\u2022"}));r+=1}}}if(n)e.appendChild(BX.create("TT",{props:{className:n}})).appendChild(l);else e.appendChild(l)}var a=h;if(e!=null){var c=0,u=l.anchor=BX.create("TT",{props:{className:"bxce-anchor"}});a=function(t,s,r){var o=s.length;if(e>=c&&e<c+o){if(e>c){h(t,s.slice(0,e-c),r);if(i)t.appendChild(BX.create("WBR"))}t.appendChild(u);var l=e-c;h(u,BX.browser.IsOpera()?s.slice(l,l+1):s.slice(l),r);if(BX.browser.IsOpera())h(t,s.slice(l+1),r);e--;c+=o}else{c+=o;h(t,s,r);if(c==e&&c==g){BX.adjust(u,{text:n.GetEolHtml()});t.appendChild(u)}else if(c>e+10&&/\s/.test(s)){a=function(){}}}}}var f=this.styles,p=this.text,d=this.marked;var g=p.length;function m(t){if(!t)return null;return"bxce-"+t.replace(/ +/g," bxce-")}if(!p&&e==null){a(l," ")}else if(!d||!d.length){for(var S=0,v=0;v<g;S+=2){var x=f[S],C=f[S+1],y=x.length;if(v+y>g)x=x.slice(0,g-v);v+=y;a(l,x,m(C))}}else{var b=0,S=0,T="",C,I=0;var L=d[0].from||0,w=[],A=0;var E=function(){var t;while(A<d.length&&((t=d[A]).from==b||t.from==null)){if(t.style!=null)w.push(t);++A}L=A<d.length?d[A].from:Infinity;for(var e=0;e<w.length;++e){var i=w[e].to;if(i==null)i=Infinity;if(i==b)w.splice(e--,1);else L=Math.min(i,L)}};var k=0;while(b<g){if(L==b)E();var B=Math.min(g,L);while(true){if(T){var N=b+T.length;var D=C;for(var M=0;M<w.length;++M)D=(D?D+" ":"")+w[M].style;a(l,N>B?T.slice(0,B-b):T,D);if(N>=B){T=T.slice(B-b);b=B;break}b=N}T=f[S++];C=m(f[S++])}}}return l},cleanUp:function(){this.parent=null;if(this.marked){for(var t=0,e=this.marked.length;t<e;++t)this.marked[t].detach(this)}},GetEolHtml:function(){if(this._eolHtml!=undefined)return this._eolHtml;this._eolHtml=" ";if(BX.browser.IsFirefox()||BX.browser.IsIE())this._eolHtml="\u200b";else if(BX.browser.IsOpera())this._eolHtml="";return this._eolHtml}};function n(t,e,i,n){for(var s=0,r=0,o=0;r<e;s+=2){var l=i[s],h=r+l.length;if(o==0){if(h>t)n.push(l.slice(t-r,Math.min(l.length,e-r)),i[s+1]);if(h>=t)o=1}else if(o==1){if(h>e)n.push(l.slice(0,e-r),i[s+1]);else n.push(l,i[s+1])}r=h}}function s(t){this.lines=t;this.parent=null;for(var e=0,i=t.length,n=0;e<i;++e){t[e].parent=this;n+=t[e].height}this.height=n}s.prototype={GetSize:function(){return this.lines.length},Remove:function(t,e,i){for(var n=t,s=t+e;n<s;++n){var r=this.lines[n];this.height-=r.height;r.cleanUp();if(r.handlers){for(var o=0;o<r.handlers.length;++o)i.push(r.handlers[o])}}this.lines.splice(t,e)},Collapse:function(t){t.splice.apply(t,[t.length,0].concat(this.lines))},SetHeight:function(t,e,i){this.height+=i;this.lines=this.lines.slice(0,t).concat(e).concat(this.lines.slice(t));for(var n=0,s=e.length;n<s;++n)e[n].parent=this},_Iteration:function(t,e,i){for(var n=t+e;t<n;++t)if(i(this.lines[t]))return true}};function r(t){this.children=t;var e,i=0,n=0;for(e=0;e<t.length;++e){i+=t[e].GetSize();n+=t[e].height;t[e].parent=this}this.size=i;this.height=n;this.parent=null}r.prototype={GetSize:function(){return this.size},Remove:function(t,e,i){this.size-=e;var n,r,o,l;for(n=0;n<this.children.length;++n){r=this.children[n],o=r.GetSize();if(t<o){l=Math.min(e,o-t),oldHeight=r.height;r.Remove(t,l,i);this.height-=oldHeight-r.height;if(o==l){this.children.splice(n--,1);r.parent=null}if((e-=l)==0)break;t=0}else{t-=o}}if(this.size-e<25){var h=[];this.Collapse(h);this.children=[new s(h)];this.children[0].parent=this}},Collapse:function(t){for(var e=0,i=this.children.length;e<i;++e)this.children[e].Collapse(t)},Insert:function(t,e){var i=0;for(var n=0,s=e.length;n<s;++n)i+=e[n].height;this.SetHeight(t,e,i)},SetHeight:function(t,e,i){this.size+=e.length;this.height+=i;var n,r,o,l,h;for(n=0;n<this.children.length;++n){r=this.children[n];o=r.GetSize();if(t<=o){r.SetHeight(t,e,i);if(r.lines&&r.lines.length>50){while(r.lines.length>50){l=r.lines.splice(r.lines.length-25,25);h=new s(l);r.height-=h.height;this.children.splice(n+1,0,h);h.parent=this}this.CheckSpill()}break}t-=o}},CheckSpill:function(){if(this.children.length<=10)return;var t,e,i,n=this;do{t=n.children.splice(n.children.length-5,5);e=new r(t);if(!n.parent){i=new r(n.children);i.parent=n;n.children=[i,e];n=i}else{n.size-=e.size;n.height-=e.height;n.parent.children.splice(p(n.parent.children,n)+1,0,e)}e.parent=n.parent}while(n.children.length>10);n.parent.CheckSpill()},Iteration:function(t,e,i){this._Iteration(t,e-t,i)},_Iteration:function(t,e,i){var n,s,r;for(n=0;n<this.children.length;++n){r=this.children[n].GetSize();if(t<r){s=Math.min(e,r-t);if(this.children[n]._Iteration(t,s,i))return true;if((e-=s)==0)break;t=0}else{t-=r}}}};function o(t){if(t.parent==null)return null;var e=t.parent,i=p(e.lines,t);for(var n=e.parent;n;e=n,n=n.parent){for(var s=0,r=n.children.length;;++s){if(n.children[s]==e)break;i+=n.children[s].GetSize()}}return i}function h(){this.time=0;this.done=[];this.undone=[];this.compound=0;this.closed=false}h.prototype={addChange:function(t,e,i){this.undone.length=0;var n=+new Date,s=this.done[this.done.length-1],r=s&&s[s.length-1];var o=n-this.time;if(this.compound&&s&&!this.closed){s.push({start:t,added:e,old:i})}else if(o>400||!r||this.closed||r.start>t+i.length||r.start+r.added<t){this.done.push([{start:t,added:e,old:i}]);this.closed=false}else{var l=Math.max(0,r.start-t),h=Math.max(0,t+i.length-(r.start+r.added));for(var a=l;a>0;--a)r.old.unshift(i[a-1]);for(var a=h;a>0;--a)r.old.push(i[i.length-a]);if(l)r.start=t;r.added+=e-(i.length-l-h)}this.time=n},startCompound:function(){if(!this.compound++)this.closed=true},endCompound:function(){if(!--this.compound)this.closed=true}};function a(t){var e=t.which;if(e==null){if(t.button&1)e=1;else if(t.button&2)e=3;else if(t.button&4)e=2}if(BX.browser.IsMac()&&t.ctrlKey&&e==1)e=3;return e}function c(){this.id=null}c.prototype={set:function(t,e){clearTimeout(this.id);this.id=setTimeout(e,t)}};function u(t,e,i){i=4;if(e==null){e=t.search(/[^\s\u00a0]/);if(e==-1)e=t.length}for(var n=0,s=0;n<e;++n){if(t.charAt(n)=="\t")s+=i-s%i;else++s}return s}function f(t,e){try{var i=t.getBoundingClientRect();i={top:i.top,left:i.left}}catch(t){i={top:0,left:0}}if(!e){if(window.pageYOffset==null){var n=document.documentElement||document.body.parentNode;if(n.scrollTop==null)n=document.body;i.top+=n.scrollTop;i.left+=n.scrollLeft}else{i.top+=window.pageYOffset;i.left+=window.pageXOffset}}return i}function p(t,e){if(t.indexOf)return t.indexOf(e);if(t.length){for(var i=0;i<t.length;++i)if(t[i]==e)return i}return-1}function d(t){return/\w/.test(t)||t.toUpperCase()!=t.toLowerCase()}{var g={};function m(t,e){if(e===true)return e;if(t.copyStatus)return t.copyStatus(e);var i={},n;for(n in e){var s=e[n];if(s instanceof Array)s=s.concat([]);i[n]=s}return i}function S(t){var e={},i;for(i=0;i<t.length;++i)e[t[i]]=true;return e}g.html=function(){var t=4,e={autoSelfClosers:S(["area","base","br","col","command","embed","frame","hr","img","input","keygen","link","meta","param","source","track","wbr"]),implicitlyClosed:S(["dd","li","optgroup","option","p","rp","rt","tbody","td","tfoot","th","tr"]),contextGrabbers:{dd:S(["dd","dt"]),dt:S(["dd","dt"]),li:S(["li"]),option:S(["option","optgroup"]),optgroup:S(["optgroup"]),p:S(["address","article","aside","blockquote","dir","div","dl","fieldset","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","menu","nav","ol","p","pre","section","table","ul"]),rp:S(["rp","rt"]),rt:S(["rp","rt"]),tbody:S(["tbody","tfoot"]),td:S(["td","th"]),tfoot:S(["tbody"]),th:S(["td","th"]),thead:S(["tbody","tfoot"]),tr:S(["tr"])},doNotIndent:S(["pre"]),allowUnquoted:true,allowMissing:true},i,n;function s(t,e){function s(i){e.tokenize=i;return i(t,e)}var o=t.next(),a,c;if(o=="<"){if(t.eat("!")){if(t.eat("[")){return t.match("CDATA[")?s(l("atom","]]>")):null}else if(t.match("--")){return s(l("comment","--\x3e"))}else if(t.match("DOCTYPE",true,true)){t.eatWhile(/[\w\._\-]/);return s(h(1))}else{return null}}else if(t.eat("?")){t.eatWhile(/[\w\._\-]/);e.tokenize=l("meta","?>");return"meta"}else{n=t.eat("/")?"closeTag":"openTag";t.eatSpace();i="";while(a=t.eat(/[^\s\u00a0=<>\"\'\/?]/))i+=a;e.tokenize=r;return"tag"}}else if(o=="&"){if(t.eat("#"))c=t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";");else c=t.eatWhile(/[\w\.\-:]/)&&t.eat(";");return c?"atom":"error"}else{t.eatWhile(/[^&<]/);return null}}function r(t,e){var i=t.next();if(i==">"||i=="/"&&t.eat(">")){e.tokenize=s;n=i==">"?"endTag":"selfcloseTag";return"tag"}else if(i=="="){n="equals";return null}else if(/[\'\"]/.test(i)){e.tokenize=o(i);return e.tokenize(t,e)}else{t.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);return"word"}}function o(t){return function(e,i){while(!e.eol()){if(e.next()==t){i.tokenize=r;break}}return"string"}}function l(t,e){return function(i,n){while(!i.eol()){if(i.match(e)){n.tokenize=s;break}i.next()}return t}}function h(t){return function(e,i){var n;while((n=e.next())!=null){if(n=="<"){i.tokenize=h(t+1);return i.tokenize(e,i)}else if(n==">"){if(t==1){i.tokenize=s;break}else{i.tokenize=h(t-1);return i.tokenize(e,i)}}}return"meta"}}var a,c;function u(){for(var t=arguments.length-1;t>=0;t--)a.cc.push(arguments[t])}function f(){u.apply(null,arguments);return true}function p(t,i){var n=e.doNotIndent.hasOwnProperty(t)||a.context&&a.context.noIndent;a.context={prev:a.context,tagName:t,indent:a.indented,startOfLine:i,noIndent:n}}function d(){if(a.context)a.context=a.context.prev}function g(t){if(t=="openTag"){a.tagName=i;return f(C,m(a.startOfLine))}else if(t=="closeTag"){var n=false;if(a.context){if(a.context.tagName!=i){if(e.implicitlyClosed.hasOwnProperty(a.context.tagName.toLowerCase()))d();n=!a.context||a.context.tagName!=i}}else{n=true}if(n)c="error";return f(v(n))}return f()}function m(t){return function(i){if(i=="selfcloseTag"||i=="endTag"&&e.autoSelfClosers.hasOwnProperty(a.tagName.toLowerCase())){x(a.tagName.toLowerCase());return f()}if(i=="endTag"){x(a.tagName.toLowerCase());p(a.tagName,t);return f()}return f()}}function v(t){return function(e){if(t)c="error";if(e=="endTag"){d();return f()}c="error";return f(arguments.callee)}}function x(t){var i;while(true){if(!a.context)return;i=a.context.tagName.toLowerCase();if(!e.contextGrabbers.hasOwnProperty(i)||!e.contextGrabbers[i].hasOwnProperty(t))return;d()}}function C(t){if(t=="word"){c="attribute";return f(y,C)}if(t=="endTag"||t=="selfcloseTag"){return u()}c="error";return f(C)}function y(t){if(t=="equals")return f(b,C);if(!e.allowMissing)c="error";return t=="endTag"||t=="selfcloseTag"?u():f()}function b(t){if(t=="string"){return f(T)}if(t=="word"&&e.allowUnquoted){c="string";return f()}c="error";return t=="endTag"||t=="selfCloseTag"?u():f()}function T(t){return t=="string"?f(T):u()}return{startStatus:function(){return{tokenize:s,cc:[],indented:0,startOfLine:true,tagName:null,context:null}},HandleChar:function(t,e){if(t.sol()){e.startOfLine=true;e.indented=t.indentation()}if(t.eatSpace())return null;c=n=i=null;var s=e.tokenize(t,e);e.type=n;if((s||n)&&s!="comment"){a=e;while(true){var r=e.cc.pop()||g;if(r(n||s))break}}e.startOfLine=false;return c||s},Indent:function(e,i,n){var o=e.context;if(e.tokenize!=r&&e.tokenize!=s||o&&o.noIndent)return n?n.match(/^(\s*)/)[0].length:0;if(o&&/^<\//.test(i))o=o.prev;while(o&&!o.startOfLine)o=o.prev;if(o)return o.indent+t;else return 0},compareStates:function(t,e){if(t.indented!=e.indented||t.tokenize!=e.tokenize)return false;for(var i=t.context,n=e.context;;i=i.prev,n=n.prev){if(!i||!n)return i==n;if(i.tagName!=n.tagName||i.indent!=n.indent)return false}},magicSym:"/"}};g.js=function(){var t=4;var e={};var i=function(){function t(t){return{type:t,style:"keyword"}}var e=t("keyword a"),i=t("keyword b"),n=t("keyword c"),s=t("var"),r=t("operator"),o={type:"atom",style:"atom"};return{if:e,while:e,with:e,else:i,do:i,try:i,finally:i,return:n,break:n,continue:n,new:n,delete:n,throw:n,var:s,const:s,let:s,function:t("function"),catch:t("catch"),for:t("for"),switch:t("switch"),case:t("case"),default:t("default"),in:r,typeof:r,instanceof:r,true:o,false:o,null:o,undefined:o,NaN:o,Infinity:o}}();var n=/[+\-*&%=<>!?|]/;function s(t,e,i){e.tokenize=i;return i(t,e)}function r(t,e){var i=false,n;while((n=t.next())!=null){if(n==e&&!i)return false;i=!i&&n=="\\"}return i}var o,l;function h(t,e,i){o=t;l=i;return e}function a(t,e){var o,l=t.next();if(l=='"'||l=="'"){o=s(t,e,c(l))}else if(/[\[\]{}\(\),;\:\.]/.test(l)){o=h(l)}else if(l=="0"&&t.eat(/x/i)){t.eatWhile(/[\da-f]/i);o=h("number","number")}else if(/\d/.test(l)||l=="-"&&t.eat(/\d/)){t.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);o=h("number","number")}else if(l=="/"){if(t.eat("*")){o=s(t,e,u)}else if(t.eat("/")){t.skipToEnd();o=h("comment","comment")}else if(e.reAllowed){r(t,"/");t.eatWhile(/[gimy]/);o=h("regexp","string-2")}else{t.eatWhile(n);o=h("operator",null,t.current())}}else if(l=="#"){t.skipToEnd();o=h("error","error")}else if(n.test(l)){t.eatWhile(n);o=h("operator",null,t.current())}else{t.eatWhile(/[\w\$_]/);var a=t.current(),f=i.propertyIsEnumerable(a)&&i[a];o=f&&e.kwAllowed?h(f.type,f.style||f.type,a):h("variable","variable",a)}return o}function c(t){return function(e,i){if(!r(e,t))i.tokenize=a;return h("string","string")}}function u(t,e){var i=false,n;while(n=t.next()){if(n=="/"&&i){e.tokenize=a;break}i=n=="*"}return h("comment","comment")}var f={atom:true,number:true,variable:true,string:true,regexp:true};function p(t,e,i,n,s,r){this.indented=t;this.column=e;this.type=i;this.prev=s;this.info=r;if(n!=null)this.align=n}function d(t,e){for(var i=t.localVars;i;i=i.next)if(i.name==e)return true}function g(t,e,i,n,s){var r=t.cc;m.status=t;m.stream=s;m.marked=null,m.cc=r;if(!t.lexical.hasOwnProperty("align"))t.lexical.align=true;while(true){var o=r.length?r.pop():w;if(o(i,n)){while(r.length&&r[r.length-1].lex)r.pop()();if(m.marked)return m.marked;if(i=="variable"&&d(t,n))return"variable-2";return e}}}var m={status:null,column:null,marked:null,cc:null};function S(){for(var t=arguments.length-1;t>=0;t--)m.cc.push(arguments[t])}function v(){S.apply(null,arguments);return true}function x(t){var e=m.status;if(e.context){m.marked="def";for(var i=e.localVars;i;i=i.next)if(i.name==t)return;e.localVars={name:t,next:e.localVars}}}var C={name:"this",next:{name:"arguments"}};function y(){if(!m.status.context)m.status.localVars=C;m.status.context={prev:m.status.context,vars:m.status.localVars}}function b(){m.status.localVars=m.status.context.vars;m.status.context=m.status.context.prev}function T(t,e){var i=function(){var i=m.status;i.lexical=new p(i.indented,m.stream.column(),t,null,i.lexical,e)};i.lex=true;return i}function I(){var t=m.status;if(t.lexical.prev){if(t.lexical.type==")")t.indented=t.lexical.indented;t.lexical=t.lexical.prev}}I.lex=true;function L(t){return function e(i){if(i==t)return v();else if(t==";")return S();else return v(arguments.callee)}}function w(t){if(t=="var")return v(T("vardef"),O,L(";"),I);if(t=="keyword a")return v(T("form"),A,w,I);if(t=="keyword b")return v(T("form"),w,I);if(t=="{")return v(T("}"),R,I);if(t==";")return v();if(t=="function")return v(G);if(t=="for")return v(T("form"),L("("),T(")"),H,L(")"),I,w,I);if(t=="variable")return v(T("stat"),B);if(t=="switch")return v(T("form"),A,T("}","switch"),L("{"),R,I,I);if(t=="case")return v(A,L(":"));if(t=="default")return v(L(":"));if(t=="catch")return v(T("form"),y,L("("),U,L(")"),w,I,b);return S(T("stat"),A,L(";"),I)}function A(t){if(f.hasOwnProperty(t))return v(k);if(t=="function")return v(G);if(t=="keyword c")return v(E);if(t=="(")return v(T(")"),E,L(")"),I,k);if(t=="operator")return v(A);if(t=="[")return v(T("]"),M(A,"]"),I,k);if(t=="{")return v(T("}"),M(D,"}"),I,k);return v()}function E(t){if(t.match(/[,;\}\)\]]/))return S();return S(A)}function k(t,e){if(t=="operator"&&/\+\+|--/.test(e))return v(k);if(t=="operator"&&e=="?")return v(A,L(":"),A);if(t==";")return;if(t=="(")return v(T(")"),M(A,")"),I,k);if(t==".")return v(N,k);if(t=="[")return v(T("]"),A,L("]"),I,k)}function B(t){if(t==":")return v(I,w);return S(k,L(";"),I)}function N(t){if(t=="variable"){m.marked="property";return v()}}function D(t){if(t=="variable")m.marked="property";if(f.hasOwnProperty(t))return v(L(":"),A)}function M(t,e){function i(n){if(n==",")return v(t,i);if(n==e)return v();return v(L(e))}return function n(s){if(s==e)return v();else return S(t,i)}}function R(t){if(t=="}")return v();return S(w,R)}function O(t,e){if(t=="variable"){x(e);return v(X)}return v()}function X(t,e){if(e=="=")return v(A,X);if(t==",")return v(O)}function H(t){if(t=="var")return v(O,_);if(t==";")return S(_);if(t=="variable")return v(P);return S(_)}function P(t,e){if(e=="in")return v(A);return v(k,_)}function _(t,e){if(t==";")return v(z);if(e=="in")return v(A);return v(A,L(";"),z)}function z(t){if(t!=")")v(A)}function G(t,e){if(t=="variable"){x(e);return v(G)}if(t=="(")return v(T(")"),y,M(U,")"),I,w,b)}function U(t,e){if(t=="variable"){x(e);return v()}}return{startStatus:function(i){return{tokenize:a,reAllowed:true,kwAllowed:true,cc:[],lexical:new p((i||0)-t,0,"block",false),localVars:e.localVars,context:e.localVars&&{vars:e.localVars},indented:0}},HandleChar:function(t,e){if(t.sol()){if(!e.lexical.hasOwnProperty("align"))e.lexical.align=false;e.indented=t.indentation()}if(t.eatSpace())return null;var i=e.tokenize(t,e);if(o=="comment")return i;e.reAllowed=!!(o=="operator"||o=="keyword c"||o.match(/^[\[{}\(,;:]$/));e.kwAllowed=o!=".";return g(e,i,o,l,t)},Indent:function(e,i){if(e.tokenize!=a)return 0;var n=i&&i.charAt(0),s=e.lexical;if(s.type=="stat"&&n=="}")s=s.prev;var r=s.type,o=n==r,l=s.indented+(o?0:t);if(r=="vardef")l=s.indented+4;else if(r=="form"&&n=="{")l=s.indented;else if(r=="stat"||r=="form")l=s.indented+t;else if(s.info=="switch"&&!o)l=s.indented+(/^(?:case|default)\b/.test(i)?t:2*t);else if(s.align)l=s.column+(o?0:1);return l},magicSym:":{}"}};g.sql=function(){var t=4,e,i=new RegExp("^(?:"+"str|lang|langmatches|datatype|bound|sameterm|isiri|isuri|isblank|isliteral|union|a"+")$","i"),n=new RegExp("^(?:"+"ACCESSIBLE|ALTER|AS|BEFORE|BINARY|BY|CASE|CHARACTER|COLUMN|CONTINUE|CROSS|CURRENT_TIMESTAMP|DATABASE|DAY_MICROSECOND|DEC|DEFAULT|DESC|DISTINCT|DOUBLE|EACH|ENCLOSED|EXIT|FETCH|FLOAT8|FOREIGN|GRANT|HIGH_PRIORITY|HOUR_SECOND|IN|INNER|INSERT|INT2|INT8|INTO|JOIN|KILL|LEFT|LINEAR|LOCALTIME|LONG|LOOP|MATCH|MEDIUMTEXT|MINUTE_SECOND|NATURAL|NULL|OPTIMIZE|OR|OUTER|PRIMARY|RANGE|READ_WRITE|REGEXP|REPEAT|RESTRICT|RIGHT|SCHEMAS|SENSITIVE|SHOW|SPECIFIC|SQLSTATE|SQL_CALC_FOUND_ROWS|STARTING|TERMINATED|TINYINT|TRAILING|UNDO|UNLOCK|USAGE|UTC_DATE|VALUES|VARCHARACTER|WHERE|WRITE|ZEROFILL|ALL|AND|ASENSITIVE|BIGINT|BOTH|CASCADE|CHAR|COLLATE|CONSTRAINT|CREATE|CURRENT_TIME|CURSOR|DAY_HOUR|DAY_SECOND|DECLARE|DELETE|DETERMINISTIC|DIV|DUAL|ELSEIF|EXISTS|FALSE|FLOAT4|FORCE|FULLTEXT|HAVING|HOUR_MINUTE|IGNORE|INFILE|INSENSITIVE|INT1|INT4|INTERVAL|ITERATE|KEYS|LEAVE|LIMIT|LOAD|LOCK|LONGTEXT|MASTER_SSL_VERIFY_SERVER_CERT|MEDIUMINT|MINUTE_MICROSECOND|MODIFIES|NO_WRITE_TO_BINLOG|ON|OPTIONALLY|OUT|PRECISION|PURGE|READS|REFERENCES|RENAME|REQUIRE|REVOKE|SCHEMA|SELECT|SET|SPATIAL|SQLEXCEPTION|SQL_BIG_RESULT|SSL|TABLE|TINYBLOB|TO|TRUE|UNIQUE|UPDATE|USING|UTC_TIMESTAMP|VARCHAR|WHEN|WITH|YEAR_MONTH|ADD|ANALYZE|ASC|BETWEEN|BLOB|CALL|CHANGE|CHECK|CONDITION|CONVERT|CURRENT_DATE|CURRENT_USER|DATABASES|DAY_MINUTE|DECIMAL|DELAYED|DESCRIBE|DISTINCTROW|DROP|ELSE|ESCAPED|EXPLAIN|FLOAT|FOR|FROM|GROUP|HOUR_MICROSECOND|IF|INDEX|INOUT|INT|INT3|INTEGER|IS|KEY|LEADING|LIKE|LINES|LOCALTIMESTAMP|LONGBLOB|LOW_PRIORITY|MEDIUMBLOB|MIDDLEINT|MOD|NOT|NUMERIC|OPTION|ORDER|OUTFILE|PROCEDURE|READ|REAL|RELEASE|REPLACE|RETURN|RLIKE|SECOND_MICROSECOND|SEPARATOR|SMALLINT|SQL|SQLWARNING|SQL_SMALL_RESULT|STRAIGHT_JOIN|THEN|TINYTEXT|TRIGGER|UNION|UNSIGNED|USE|UTC_TIME|VARBINARY|VARYING|WHILE|XOR|FULL|COLUMNS|MIN|MAX|STDEV|COUNT"+")$","i"),s=/[*+\-<>=&|]/;function r(t,r){var h=t.next();e=null;if(h=="$"||h=="?"){t.match(/^[\w\d]*/);return"variable-2"}else if(h=="<"&&!t.match(/^[\s\u00a0=]/,false)){t.match(/^[^\s\u00a0>]*>?/);return"atom"}else if(h=='"'||h=="'"){r.tokenize=o(h);return r.tokenize(t,r)}else if(h=="`"){r.tokenize=l(h);return r.tokenize(t,r)}else if(/[{}\(\),\.;\[\]]/.test(h)){e=h;return null}else if(h=="-"){var a=t.next();if(a=="-"){t.skipToEnd();return"comment"}}else if(s.test(h)){t.eatWhile(s);return null}else if(h==":"){t.eatWhile(/[\w\d\._\-]/);return"atom"}else{t.eatWhile(/[_\w\d]/);if(t.eat(":")){t.eatWhile(/[\w\d_\-]/);return"atom"}var c=t.current(),u;if(i.test(c))return null;else if(n.test(c))return"keyword";else return"variable"}}function o(t){return function(e,i){var n=false,s;while((s=e.next())!=null){if(s==t&&!n){i.tokenize=r;break}n=!n&&s=="\\"}return"string"}}function l(t){return function(e,i){var n=false,s;while((s=e.next())!=null){if(s==t&&!n){i.tokenize=r;break}n=!n&&s=="\\"}return"variable-2"}}function h(t,e,i){t.context={prev:t.context,indent:t.indent,col:i,type:e}}function a(t){t.indent=t.context.indent;t.context=t.context.prev}return{startStatus:function(t){return{tokenize:r,context:null,indent:0,col:0}},HandleChar:function(t,i){if(t.sol()){if(i.context&&i.context.align==null)i.context.align=false;i.indent=t.indentation()}if(t.eatSpace())return null;var n=i.tokenize(t,i);if(n!="comment"&&i.context&&i.context.align==null&&i.context.type!="pattern")i.context.align=true;if(e=="("){h(i,")",t.column())}else if(e=="["){h(i,"]",t.column())}else if(e=="{"){h(i,"}",t.column())}else if(/[\]\}\)]/.test(e)){while(i.context&&i.context.type=="pattern")a(i);if(i.context&&e==i.context.type)a(i)}else if(e=="."&&i.context&&i.context.type=="pattern"){a(i)}else if(/atom|string|variable/.test(n)&&i.context){if(/[\}\]]/.test(i.context.type)){h(i,"pattern",t.column())}else if(i.context.type=="pattern"&&!i.context.align){i.context.align=true;i.context.col=t.column()}}return n},Indent:function(e,i){var n=i&&i.charAt(0),s=e.context;if(/[\]\}]/.test(n)){while(s&&s.type=="pattern")s=s.prev}var r=s&&n==s.type,o=s.indent+(r?0:t);if(!s)o=0;else if(s.type=="pattern")o=s.col;else if(s.align)o=s.col+(r?0:1);return o}}};g.phpcore=function(){var t=4,e=S(["echo","include","require","include_once","require_once","for","foreach","as","endswitch","return","break","continue","null","__LINE__","__FILE__","var","default","function","class","new","&amp;new","this","__FUNCTION__","__CLASS__","__METHOD__","PHP_VERSION","E_ERROR","E_WARNING","E_PARSE","E_NOTICE","E_CORE_ERROR","E_CORE_WARNING","E_COMPILE_ERROR","E_COMPILE_WARNING","E_USER_ERROR","E_USER_WARNING","E_USER_NOTICE","E_ALL","abstract","array"]),i=S(["catch","do","else","elseif","for","foreach","if","switch","try","while","endwhile","endif","case"]),n=S(["true","false","null","TRUE","FALSE","NULL"]),s={$:function(t,e){t.eatWhile(/[\w\$_]/);return"variable-2"},"<":function(t,e){if(t.match(/<</)){t.eatWhile(/[\w\.]/);var i=t.current().slice(3);e.tokenize=function(t,e){if(t.match(i))e.tokenize=null;else t.skipToEnd();return"string"};return e.tokenize(t,e)}return false},"#":function(t,e){while(!t.eol()&&!t.match("?>",false))t.next();return"comment"},"/":function(t,e){if(t.eat("/")){while(!t.eol()&&!t.match("?>",false))t.next();return"comment"}return false}},r=true,o=/[+\-*&%=<>!?|\/]/,l;function h(t,r){var h=t.next();if(s[h]){var u=s[h](t,r);if(u!==false)return u}if(h=='"'||h=="'"){r.tokenize=a(h);return r.tokenize(t,r)}if(/[\[\]{}\(\),;\:\.]/.test(h)){l=h;return null}if(/\d/.test(h)){t.eatWhile(/[\w\.]/);return"number"}if(h=="/"){if(t.eat("*")){r.tokenize=c;return c(t,r)}if(t.eat("/")){t.skipToEnd();return"comment"}}if(o.test(h)){t.eatWhile(o);return"operator"}t.eatWhile(/[\w\$_]/);var f=t.current();if(e.propertyIsEnumerable(f)){if(i.propertyIsEnumerable(f))l="newstatement";return"keyword"}if(n.propertyIsEnumerable(f))return"atom";return"variable"}function a(t){return function(e,i){var n=false,s,o=false;while((s=e.next())!=null){if(s==t&&!n){o=true;break}n=!n&&s=="\\"}if(o||!(n||r))i.tokenize=null;return"string"}}function c(t,e){var i=false,n;while(n=t.next()){if(n=="/"&&i){e.tokenize=null;break}i=n=="*"}return"comment"}function u(t,e,i,n,s){this.indented=t;this.column=e;this.type=i;this.align=n;this.prev=s}function f(t,e,i){return t.context=new u(t.indented,e,i,null,t.context)}function p(t){var e=t.context.type;if(e==")"||e=="]"||e=="}")t.indented=t.context.indented;return t.context=t.context.prev}return{startStatus:function(e){return{tokenize:null,context:new u((e||0)-t,0,"top",false),indented:0,startOfLine:true}},HandleChar:function(t,e){var i=e.context;if(t.sol()){if(i.align==null)i.align=false;e.indented=t.indentation();e.startOfLine=true}if(t.eatSpace())return null;l=null;var n=(e.tokenize||h)(t,e);if(n=="comment"||n=="meta")return n;if(i.align==null)i.align=true;if((l==";"||l==":")&&i.type=="statement"){p(e)}else if(l=="{"){f(e,t.column(),"}")}else if(l=="["){f(e,t.column(),"]")}else if(l=="("){f(e,t.column(),")")}else if(l=="}"){while(i.type=="statement")i=p(e);if(i.type=="}")i=p(e);while(i.type=="statement")i=p(e)}else if(l==i.type){p(e)}else if(i.type=="}"||i.type=="top"||i.type=="statement"&&l=="newstatement"){f(e,t.column(),"statement")}e.startOfLine=false;return n},Indent:function(e,i){if(e.tokenize!=h&&e.tokenize!=null)return 0;var n=e.context,s=i&&i.charAt(0);if(n.type=="statement"&&s=="}")n=n.prev;if(n.type=="statement")return n.indented+(s=="{"?0:t);else if(n.align)return n.column+(s==n.type?0:1);else return n.indented+(s==n.type?0:t)},magicSym:"{}"}};g.css=function(){var t=4,e;var i=S(["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","auto","avoid","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break-all","break-word","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","compact","condensed","contain","content","content-box","context-menu","continuous","copy","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","navy","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","overlay","overline","padding","padding-box","painted","paused","persian","plus-darker","plus-lighter","pointer","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","semi-condensed","semi-expanded","separate","serif","show","sidama","single","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","white","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small","yellow"]);function n(t,i){e=i;return t}function s(t,e){var i=t.next();if(i=="@"){t.eatWhile(/[\w\\\-]/);return n("meta",t.current())}else if(i=="/"&&t.eat("*")){e.tokenize=r;return r(t,e)}else if(i=="<"&&t.eat("!")){e.tokenize=o;return o(t,e)}else if(i=="="){return n(null,"compare")}else if((i=="~"||i=="|")&&t.eat("=")){return n(null,"compare")}else if(i=='"'||i=="'"){e.tokenize=l(i);return e.tokenize(t,e)}else if(i=="#"){t.eatWhile(/[\w\\\-]/);return n("atom","hash")}else if(i=="!"){t.match(/^\s*\w*/);return n("keyword","important")}else if(/\d/.test(i)){t.eatWhile(/[\w.%]/);return n("number","unit")}else if(/[,.+>*\/]/.test(i)){return n(null,"select-op")}else if(/[;{}:\[\]\(\)]/.test(i)){return n(null,i)}else{t.eatWhile(/[\w\\\-]/);return n("variable","variable")}}function r(t,e){var i=false,r;while((r=t.next())!=null){if(i&&r=="/"){e.tokenize=s;break}i=r=="*"}return n("comment","comment")}function o(t,e){var i=0,r;while((r=t.next())!=null){if(i>=2&&r==">"){e.tokenize=s;break}i=r=="-"?i+1:0}return n("comment","comment")}function l(t){return function(e,i){var r=false,o;while((o=e.next())!=null){if(o==t&&!r)break;r=!r&&o=="\\"}if(!r)i.tokenize=s;return n("string","string")}}return{startStatus:function(t){return{tokenize:s,baseIndent:t||0,stack:[]}},HandleChar:function(t,n){if(t.eatSpace())return null;var s=n.tokenize(t,n);var r=n.stack[n.stack.length-1];if(e=="hash"&&r!="rule"){s="string-2"}else if(s=="variable"){if(r=="rule")s=i[t.current()]?"keyword":"number";else if(!r||r=="@media{")s="tag"}if(r=="rule"&&/^[\{\};]$/.test(e)){n.stack.pop()}if(e=="{"){if(r=="@media")n.stack[n.stack.length-1]="@media{";else n.stack.push("{")}else if(e=="}"){n.stack.pop()}else if(e=="@media"){n.stack.push("@media")}else if(r=="{"&&e!="comment"){n.stack.push("rule")}return s},Indent:function(e,i){var n=e.stack.length;if(/^\}/.test(i))n-=e.stack[e.stack.length-1]=="rule"?2:1;return e.baseIndent+n*t},magicSym:"}"}};g.php=function(t){var e={},i=g.html(),n=g.js(),s=g.css(),r=g.phpcore();function o(e,l){var h,a=l.syntax=="php";if(!a&&t){l.curSyntax=r;l.curState=l.php;l.syntax="php"}if(e.sol()&&l.pending!='"')l.pending=null;if(l.curSyntax==i){if(e.match(/^<\?\w*/)){l.curSyntax=r;l.curState=l.php;l.curClose="?>";l.syntax="php";return"meta"}if(l.pending=='"'){while(!e.eol()&&e.next()!='"'){}h="string"}else if(l.pending&&e.pos<l.pending.end){e.pos=l.pending.end;h=l.pending.style}else{h=i.HandleChar(e,l.curState)}l.pending=null;var c=e.current(),u=c.search(/<\?/);if(u!=-1){if(h=="string"&&/\"$/.test(c)&&!/\?>/.test(c))l.pending='"';else l.pending={end:e.pos,style:h};e.backUp(c.length-u)}else if(h=="tag"&&e.current()==">"&&l.curState.context){if(/^script$/i.test(l.curState.context.tagName)){l.curSyntax=n;l.curState=n.startStatus(i.Indent(l.curState,""));l.curClose=/^<\/\s*script\s*>/i;l.syntax="js"}else if(/^style$/i.test(l.curState.context.tagName)){l.curSyntax=s;l.curState=s.startStatus(i.Indent(l.curState,""));l.curClose=/^<\/\s*style\s*>/i;l.syntax="css"}}return h}else if((!a||l.php.tokenize==null)&&e.match(l.curClose,a)){l.curSyntax=i;l.curState=l.html;l.curClose=null;l.syntax="html";return a?"meta":o(e,l)}else{return l.curSyntax.HandleChar(e,l.curState)}}return{startStatus:function(){var t=i.startStatus();return{html:t,php:r.startStatus(),curSyntax:e.startOpen?r:i,curState:e.startOpen?r.startStatus():t,curClose:e.startOpen?/^\?>/:null,syntax:e.startOpen?"php":"html",pending:null}},copyStatus:function(t){var e=t.html,n=m(i,e),s=t.php,o=m(r,s),l;if(t.curState==e)l=n;else if(t.curState==s)l=o;else l=m(t.curSyntax,t.curState);return{html:n,php:o,curSyntax:t.curSyntax,curState:l,curClose:t.curClose,syntax:t.syntax,pending:t.pending}},HandleChar:o,Indent:function(t,e){if(t.curSyntax!=r&&/^\s*<\//.test(e)||t.curSyntax==r&&/^\?>/.test(e))return i.Indent(t.html,e);return t.curSyntax.Indent(t.curState,e)},magicSym:"/{}:"}}}function v(t,e,i,n){this.from=t;this.to=e;this.style=i;this.marker=n}v.prototype={attach:function(t){this.marker.set.push(t)},detach:function(t){var e=p(this.marker.set,t);if(e>-1)this.marker.set.splice(e,1)},split:function(t,e){if(this.to<=t&&this.to!=null)return null;var i=this.from<t||this.from==null?null:this.from-t+e,n=this.to==null?null:this.to-t+e;return new v(i,n,this.style,this.marker)},dup:function(){return new v(null,null,this.style,this.marker)},clipTo:function(t,e,i,n,s){if(t&&n>this.from&&(n<this.to||this.to==null))this.from=null;else if(this.from!=null&&this.from>=e)this.from=Math.max(n,this.from)+s;if(i&&(e<this.to||this.to==null)&&(e>this.from||this.from==null))this.to=null;else if(this.to!=null&&this.to>e)this.to=n<this.to?this.to+s:e},isDead:function(){return this.from!=null&&this.to!=null&&this.from>=this.to},sameSet:function(t){return this.marker==t.marker}}})();
//# sourceMappingURL=code-editor.map.js